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
9 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.

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

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

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
Ok, thank you. Answer accepted, upvoted. Please upvote. yoshiegg6 176 — 9y
Ad

Answer this question