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

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

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.

2 comments

0

You should not be using local scripts to manage the leaderboard

0

I'm not managing the leaderboard. I'm just getting information from it and putting it in a variable.

1 answer

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

1 comment

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.

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