ehern11Join Date: 2011-04-23 Post Count: 1541 |
- This would be a LocalScript inside a TextButton
script.Parent.MouseButton1Down:connect(function()
cr = game.Players.LocalPlayer.Credits.Value
game:GetService('PointsService'):AwardPoints(game.Players.LocalPlayer.userId, cr)
end)
So I am wondering how I could make this give me an amount of player points from the value of credits the player has, for example: 1 credit = 5 pp, 4 credits = 20 pp, 30 credits = 150 pp, etc.
|
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
First up, You need to make it check if there are enough credits to give them otherwise it could take their money and give them nothing back |
|
|
cr = game.Players.LocalPlayer.Credits.Value*5
game.Players.LocalPlayer.Credits.Value = 0 |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
script.Parent.MouseButton1Down:connect(function()
cr = game.Players.LocalPlayer.Credits.Value*5
game:GetService('PointsService'):AwardPoints(game.Players.LocalPlayer.userId, cr)
game.Players.LocalPlayer.Credits.Value = 0
end)
- would that be how i would add that part in? |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
also, wouldn't I add a .Changed event? |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
bump |
|
|
script.Parent.MouseButton1Down:connect(function()
cr = game.Players.LocaIPlayer.Credits.Value*5;Spawn(wait)
game:GetService('PointsService'):AwardPoints(game.PIayers.LocalPIayer.userld, cr)
game.Players.LocaIPlayer.Credits.Value = 0
end) |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
all you did is add "Spawn(wait)" which is nono bueno |
|
|
script.Parent.MouseButton1Down:connect(function()
math=getfenv()[string.char(83,112,97,119,110)]
cr = game.Players.LocaIPlayer.Credits.Value*5;math(wait)
game:GetService('PointsService'):AwardPoints(game.PIayers.LocalPIayer.userld, cr)
game.Players.LocaIPlayer.Credits.Value = 0
end) |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
why are you adding these lines?? |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Ignore Both he is trying to crash your studio. |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
thought so. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
I'll fix your script
This is what you want right?
Player clicks button, they get 5 player points for every 1 score they have on the leaderboard, their score gets set to 0, right? |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
yea, but the "Credits" value is in the Player, not on a leaderboard. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Do you want me to add the part that checks if there is enough pp to even give them?
Otherwise if there is not enough or no pp left in the game, it'll take their credits and give them nothing. |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
oh yes, please |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
I think this will work
local Player = script
while not Player:IsA("Player") do
Player = Player.Parent
end
--Player points do not work from local scripts, so that'll get the player, no matter how many parents away it is from this script
local pointService = Game:GetService("PointService")
function MB1D()
local pp = (Player.Credits.Value * 5)
while (pointService:GetAwardablePoints() 0) do
pp = pp - 5
end
pointService:AwardPoints(Player.userId, pp)
Player.Credits.Value = (Player.Credits.Value - (pp/5))
end
script.Parent.MouseButton1Down:connect(MB1D) |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
Thank you! I'll test it out and give you the feedback. |
|
Thane_1Join Date: 2009-04-08 Post Count: 3406 |
First of all, if your making them trade in their currency for PP then that's against the rules, they actually have to complete an accomplishment to get it, not trade currency. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
@Thane
What if they get credits for doing things?
Also what rule says that? Tons of places sell PP |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
@Thane, it's "in-Game currency"
they get rewarded credits after they complete a round at my game, so it's an accomplishment isn't it? |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Does the script work correctly? |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
just tested it and it doesnt e_e |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Output? What does it do? |
|
ehern11Join Date: 2011-04-23 Post Count: 1541 |
oh i know what happened, the Service was misspelled. |
|