Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player Point script not working?

I made this script to print how many player points someone has when they touch it and it doesn't work. I've looked over the wiki page and I'm using everything they use, but it's just not working.

PS = Game:GetService("PointsService")

script.Parent.Touched:connect(function(pl)
if pl.Parent:GetPlayerFromCharacter().Parent:IsFriendsWith(30125279) then
Total = Ps:GetGamePointBalance(pl.Parent:GetPlayerFromCharacter().Parent.userID)
if Total >= 100 then
print(pl.Parent.name.."has"..Total.."points. Good job!")
else
print(pl.Parent.name.."has"..Total.."points. Try harder."

1 answer

✓ Accepted answer

I don't really like the layout of your script, so I'll rewrite it, and tell me if it works.

local pointsService = game:GetService("PointsService")

script.Parent.Touched:connect(function(part)
local player = game.Players:FindFirstChild(part.Parent.Name)
if player then
local pointBalance = pointsService:GetGamePointBalance(player.userId)
print(player.Name.." has "..pointBalance.." points. "..pointBalance >= 100 and "Good job!" else and "Try harder.") --I used ternary operators here so that there would be only one print, I know it's more code, but you could have use for it in the future. I just thought it could spice things up.
end
end)

1 comment

1

Ok, thank you. Answer accepted, upvoted. Please upvote.

This discussion is preserved as it was. New answers, comments, and votes are closed.