My script is meant to allow players to convert their cash into player points... However I have tried and tried but it never works, could anyone please fix this! This is what I have so far but I can't read the output very well and make sense of it:
points = game:GetService("PointsService") awardable = points:GetAwardablePoints() ammount = 10 function onClicked(p) if awardable >= ammount then if p.leaderstats.Cash.Value >= 50000 then p.leaderstats.Cash.Value = p.leaderstats.Cash.Value - 50000 game:GetService("PointsService"):AwardPoints(p.userId,ammount) end end end script.Parent.MouseButton1Click:connect(onClicked)
THE SCRIPT IS IN A TEXT BUTTON IF YOU NEED TO KNOW
First of all, make sure the script is a regular script rather than a local script. Local scripts are not allowed to award points. Also, the player is not passed as an argument in mouse click events. Here's how you could do it.
points = game:GetService("PointsService") awardable = points:GetAwardablePoints() ammount = 10 local p = script.Parent.Parent.Parent.Parent --This while loop goes up the object hierarchy until it reaches the player. while (not p:IsA("Player")) do p = p.Parent end function onClicked() if awardable >= ammount then if p:FindFirstChild("leaderstats") and p.leaderstats.Cash.Value >= 50000 then p.leaderstats.Cash.Value = p.leaderstats.Cash.Value - 50000 game:GetService("PointsService"):AwardPoints(p.userId,ammount) end end end script.Parent.MouseButton1Click:connect(onClicked)
try spelling amount right