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

Why doesn't this value-change... change?

Asked by
Sir_Melio 221 Moderation Voter
7 years ago
Edited 7 years ago

I'm trying to make the variable kills so that it only counts from the start of your KOs and not from 0.

kills = 0
game.Players.LocalPlayer.CharacterAdded:connect(function()
    kills = 0
    local start = game.Players.LocalPlayer.leaderstats.KOs.Value
    game.Players.LocalPlayer.leaderstats.KOs.Changed:connect(function(amount)
        kills = amount - start
    end)
end)

Example, if I had 0 kills, and get 5 kills, it will be 5 kills, ok. But in my next character respawn, (now I still have 5 kills in my leaderboard), if I get 5 more kills (10 in total), it will not say 5, it will say 10. How do I fix it so it says 5 only? And the thing saying it is the variable kills.

0
You should not be using local scripts to manage the leaderboard User#5423 17 — 7y
0
I'm not managing the leaderboard. I'm just getting information from it and putting it in a variable. Sir_Melio 221 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
kills = 0
game.Players.LocalPlayer.CharacterAdded:connect(function()
    kills = 0
    local start = game.Players.LocalPlayer.leaderstats.KOs --You can't use .Value in a variable
    game.Players.LocalPlayer.leaderstats.KOs.Changed:connect(function(amount)
        kills = amount - start.Value
    end)
end)

I don't know why, but this just happens, you can't use '.Value' when setting a variable

0
Oh, I thought that's only to change them, since I'm not setting an object value, I'm getting the value from the object and that becomes the variable. Sir_Melio 221 — 7y
Ad

Answer this question