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!
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)