The Loop will run once, but then will end, and I'm not quite sure why, Thanks for reading! In this code im attempting to make a text go in in numbers such as 1,2,3,4, esc as a way to count waves of a game, 1 second being a basis
Game_Over = game.Workspace.Values.Status.Value WaveNum = game.Workspace.Values.Wave.Value while Game_Over == false do wait(1) script.Parent.Text = WaveNum +1 end
I still don't quite understand what you're trying to do, fully, but this should help:
First, you should only save references to the ValueObjects themselves, not a specific property of them. When you update the ValueObjects, the variables don't change because you took a 'snapshot' of the Property, not a reference to it.
The loop is 'ending' because you gave it an end condition. I would suggest wrapping the loop with an infinite one:
Game_Over = game.Workspace.Values.Status --I also suggest putting these Values in ServerStorage WaveNum = game.Workspace.Values.Wave while true do while not Game_Over.Value do wait(1) WaveNum = WaveNum.Value + 1 script.Parent.Text = WaveNum.Value end Game_Over.Value = true end
It's quite simple to solve this error.
First, if you replace this == false
operator for an not
one, your code will look more professional.
Game_Over = game.Workspace.Values.Status.Value WaveNum = game.Workspace.Values.Wave.Value while not Game_Over do wait(1) script.Parent.Text = WaveNum +1 end
And then, you are replacing the code with the WaveNum
value. But you never change it, so it will be the same number forever. So we need to call an addition
before the loop ends.
-- requests the values Game_Over = game.Workspace.Values.Status.Value WaveNum = game.Workspace.Values.Wave.Value while not Game_Over do wait(1) script.Parent.Text = WaveNum +1 -- replaces the old value by the new value WaveNum = WaveNum + 1 -- adds 1 to the value end