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

This script doesn't work? Help please?

Asked by 10 years ago

I'm trying to make this so EVERY 4 KOs, you get 1 Player Point, but instead, it gives 1 Player Point after the 4 KOs. Help me please?

PointsService = game:GetService("PointsService")
Stat = "KOs"
Needed = 4

game.Players.PlayerAdded:connect(function(p)
        repeat wait() until p:FindFirstChild("leaderstats") ~= nil
        print("Found \"leaderstats\" object!")
        repeat wait() until p.leaderstats:findFirstChild(Stat) ~= nil
        print("Found "..Stat.." object!")
        p.leaderstats[Stat].Changed:connect(function(prop)
                print("Value changed!")
                if prop >= Needed then
                        wait()
                        game:GetService("PointsService"):AwardPoints(p.userId,1)
                end
        end)
end)
0
So the KOs would be 4, 8, 12.. so on and so forth. Pawsability 65 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago
PointsService = game:GetService("PointsService")
Stat = "KOs"
Needed = 4

game.Players.PlayerAdded:connect(function(p)
        repeat wait() until p:FindFirstChild("leaderstats") ~= nil
        print("Found \"leaderstats\" object!")
        repeat wait() until p.leaderstats:findFirstChild(Stat) ~= nil
        print("Found "..Stat.." object!")
        p.leaderstats[Stat].Changed:connect(function(prop)
                print("Value changed!")
                if prop >= Needed then
                        wait()
                Needed = Needed + 4 --Add 4 each time
                        game:GetService("PointsService"):AwardPoints(p.userId,1)
                end
        end)
end)
Ad

Answer this question