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

This script doesn't work? Help please?

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)

1 comment

0

So the KOs would be 4, 8, 12.. so on and so forth.

1 answer

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)

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