PointsService = game:GetService("PointsService") Stat = "KOs" Needed = 5 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 game:GetService("PointsService"):AwardPoints(p.userId,1) needed = needed +5 end end) end)
Edit: It can't be in a local script, so i'm going to need a different way to do it, probs put a value inside a player?
What i have been trying to do is increase the 'needed' by 5, but this does it for everyone on the server. Is there any way i can make this a local script and put it inside StarterGUI? (Don't know if that will break anything)
PointsService = game:GetService("PointsService") Stat = "KOs" Needed = 5 game.Players.PlayerAdded:connect(function(p) local needed = Needed p:WaitForChild('leaderstats'):WaitForChild(Stat).Changed:connect(function(prop) print("Value changed!") if prop >= needed then game:GetService("PointsService"):AwardPoints(p.userId,1) needed = needed + Needed end end) end)
Yeah, in fact it's way easier:
PointsService = game:GetService("PointsService") Stat = "KOs" Needed = 5 p = game.Players.LocalPlayer repeat wait() until p:FindFirstChild("leaderstats") ~= nil repeat wait() until p.leaderstats:findFirstChild(Stat) ~= nil p.leaderstats[Stat].Changed:connect(function(prop) print("Value changed!") if prop >= Needed then game:GetService("PointsService"):AwardPoints(p.userId,1) needed = needed +5 end end)
You know you can use the Tab
key to indent things, right?