Hello! I am currently making a game and an error occured. I was done with my stats but when I did this, it did’nt show. And there was no errors in the output. Also in my stats, when I changed the value, I checked in players, “PlayerStats” then “Wood” (Currency) and my value didn’t change.
local text = script.Parent
local plr = game.Players.LocalPlayer
while true do
wait() – This prevents it from causing a script error or shutdown. DON’T DELETE IT.
text.Text = plr:WaitForChild(“PlayerStats”).Wood.Value
end
while true do
wait(4)
plr.PlayerStats.Wood.Value = 12
end
local text = script.Parent
local plr = game.Players.LocalPlayer
while true do
wait() --This prevents it from causing a script error or shutdown. DON’T DELETE IT.
text.Text = plr:WaitForChild(“PlayerStats”).Wood.Value
end
while true do -- this will never run
wait(4)
plr.PlayerStats.Wood.Value = 12
end
local text = script.Parent
local plr = game.Players.LocalPlayer
plr:WaitForChild(“PlayerStats”).Wood.Changed:Connect(function(Wood)
text.Text = Wood.Value
end
plr.PlayerStats.Wood.Value = 12
As others have said, using a while loop will just cause the script to yield until that loop finishes. For setting the text to what the number is, instead do this:
However, note how I used the tostring function? You can’t set a string value as a number value. Using tostring will convert the number value into a string, which lets the Text value be changed.