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

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

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

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)

1 comment

0

Nope, it provides a player point after the first 5 kills, but not at the 2nd 5, (10 kills)

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.

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