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

Every 5 kills provides player points? (Just a simple fix?)

Asked by
lomo0987 250 Moderation Voter
10 years ago
PointsService = game:GetService("PointsService")
Stat = "KOs" --Change to the stats name
Needed = 5 --Change to the amount needed to get the playerpoints.
game.Players.PlayerAdded:connect(function(p)
        repeat wait() until p:FindFirstChild("leaderstats") ~= nil
        repeat wait() until p.leaderstats:findFirstChild(Stat) ~= nil
        p.leaderstats[Stat].Changed:connect(function(prop)
                if prop >= Needed then
                        game:GetService("PointsService"):AwardPoints(p.userId,1)
                end
        end)
end)

What I need to know how to do is make it so every 5 kills the player gets a player point, is there a thing such as 'i for 5 do ....' where i is kills and provides a player point for every 5 kills?

2 answers

Log in to vote
0
Answered by 10 years ago
PointsService = game:GetService("PointsService")
Stat = "KOs" --Change to the stats name
Needed = 5 --Change to the amount needed to get the playerpoints.
game.Players.PlayerAdded:connect(function(p)
        LeaderStat = p:WaitForChild("leaderstats"):WaitForChild(Stat)
        LeaderStat.Changed:connect(function()
                if LeaderStat.Value >= Needed and LeaderStat.Value % Needed == 0 then
                        game:GetService("PointsService"):AwardPoints(p.userId,1)
                end
        end)
end)
0
Nope, it provides a player point after the first 5 kills, but not at the 2nd 5, (10 kills) lomo0987 250 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

You'd probably want the script to check every time the board updates for a player, and then if KO's are equal to a multiple of five, add a player point.

Answer this question