I made this script and it works perfect in solo testing but it doesn't work in normal game.
while true do game.Players.LocalPlayer.leaderstats.Score.Value = game.Players.LocalPlayer.leaderstats.Score.Value + 1 local str = game.Players.LocalPlayer.leaderstats.Score.Value local str1 = "Your income: " game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextButton.Text = str1..str wait(1) end
The most common cause for a LocalScript
to malfunction in a sever environment is an attempt to access something that is instantiated very quickly when run locally, but more slowly on a server, for example ... the Player
!
All you need to do is add a loop that waits until the player, and in some cases the specific thing that you want, exist:
while not game.Players.LocalPlayer do wait() end player = game.Players.LocalPlayer while not player:FindFirstChild("leaderstats") do wait() end stats = player.leaderstats while true do stats.Score.Value = stats.Score.Value + 1 local str = stats.Score.Value local str1 = "Your income: " player.PlayerGui.ScreenGui.Frame.TextButton.Text = str1..str wait(1) end