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

Help with player points?

I've been stumped by player points ever since they came out. Now I have attempted to use free models and figure it out so this is what I have...

local service = game:GetService("PointsService") 

game.Players.PlayerAdded:connect(
function(Player)
	Player:waitForDataReady()
	service:AwardPoints(161887225, service:GetAwardablePoints())--My game id...
end
)

The script above is for giving the server the points I have... I think Also, this is the point awarding script...

PointsService = game:GetService("PointsService")
Stat = "KOs" 
Needed = 1 
game.Players.PlayerAdded:connect(function(p)
	repeat wait() until p:FindFirstChild("leaderstats") ~= nil --Wait until the script has found the leaderboard stats of the player
	repeat wait() until p.leaderstats:findFirstChild(Stat) ~= nil --Wait until the script has found the KOs of the player
	p.leaderstats[Stat].Changed:connect(function(prop) --Bind the KOs to the function "prop"
		if prop >= Needed then --If the KOs has changed by 1, then award 1 point
		game:GetService("PointsService"):AwardPoints(p.userId,1)
		end
	end)
end)

Can anyone help me with this?... I really don't get these player points and I want to implement them into my game as a test. P.S. I have player points in my game already.

1 answer

Well, for the first script, are you trying to give the player All of your player Points? Also, you made an error in line 6. It's supposed to be their userId. Also, for line 5, WaitforDataReady is used for data persistance. Here's it corrected.

local service = game:GetService("PointsService") 

game.Players.PlayerAdded:connect(
function(Player)
    repeat wait until Player:findFirstChild("PlayerGui")
    service:AwardPoints(Player.userId, service:GetAwardablePoints())--My game id...
end)

Your 2nd script seems to be functioning fine.

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