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

how to fix a highscore counter with a replicated storage value?

while true do
	wait(5)
if game.ReplicatedStorage.Score.Score.Value > game.Players.LocalPlayer.leaderstats.fightscore then do
game.ReplicatedStorage.Score.Score.Value = game.ReplicatedStorage.Score.Score.Value
end
end
end

so this script is in my serverscript service i want it to only work when the status of the highscore is changed also the script wont work!

1 answer

✓ Accepted answer

Main problem: Script not working

Your script doesn't work because you set the value of the score to itself

game.ReplicatedStorage.Score.Score.Value = game.ReplicatedStorage.Score.Score.Value

I guess what you're trying to do is to set the value in the leaderstats to what is in ReplicatedStorage, so:

game.Players.LocalPlayer.leaderstats.fightscore.Value = game.ReplicatedStorage.Score.Score.Value

Secondary problem:

Inserting a 5-second wait() is really inefficient. Instead, you could use :GetPropertyChangedSignal(string property), so:

game.ReplicatedStorage.Score.Score:GetPropertyChangedSignal("Value"):Connect(function()

Your fixed script would be:

game.ReplicatedStorage.Score.Score:GetPropertyChangedSignal("Value"):Connect(function()
	game.Players.LocalPlayer.leaderstats.fightscore.Value = game.ReplicatedStorage.Score.Score.Value
end)

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