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

Help with player points?

Asked by 9 years ago

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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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.

Ad

Answer this question