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

[Not answered!]Points on every 5 kills?

Asked by
lomo0987 250 Moderation Voter
10 years ago
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)

0
Edited my code. Articulating 1335 — 10y

2 answers

Log in to vote
1
Answered by 10 years ago
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)
0
we been through this before. That doesn't work. lomo0987 250 — 10y
0
Edited. Articulating 1335 — 10y
Ad
Log in to vote
-2
Answered by
Maxomega3 106
10 years ago

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?

0
That just makes the script look 'neater'. If it's a short script I don't really care about it then. lomo0987 250 — 10y
0
"Points Service requires beta access" and line 10... stack end? lomo0987 250 — 10y
0
Nvm, I just remembered it has to be in a normal script. local scripts can't access Points Service :/ lomo0987 250 — 10y

Answer this question