Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Player Point script not working?

Asked by
yoshiegg6 176
10 years ago

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.

1PS = Game:GetService("PointsService")
2 
3script.Parent.Touched:connect(function(pl)
4if pl.Parent:GetPlayerFromCharacter().Parent:IsFriendsWith(30125279) then
5Total = Ps:GetGamePointBalance(pl.Parent:GetPlayerFromCharacter().Parent.userID)
6if Total >= 100 then
7print(pl.Parent.name.."has"..Total.."points. Good job!")
8else
9print(pl.Parent.name.."has"..Total.."points. Try harder."

1 answer

Log in to vote
1
Answered by
yumtaste 476 Moderation Voter
10 years ago

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

1local pointsService = game:GetService("PointsService")
2 
3script.Parent.Touched:connect(function(part)
4local player = game.Players:FindFirstChild(part.Parent.Name)
5if player then
6local pointBalance = pointsService:GetGamePointBalance(player.userId)
7print(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.
8end
9end)
1
Ok, thank you. Answer accepted, upvoted. Please upvote. yoshiegg6 176 — 10y
Ad

Answer this question