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

why its dont work?

Hello everyone, i need a help. I have a script:

while GameStart == true do
	TimerMessage = Instance.new("Hint", game.Workspace)
	TimerMessage.Text = "This game will end in " ..TimerValue.. " seconds"
	wait(1)
	TimerValue = TimerValue - 1
	TimerMessage:remove()
end

if TimerValue == 0 then
	GameStart = false
	IsArtist = false
	TimerValue = 120
end

and when value TimerValue = 0 loop doesnt stop. halp. Sorry for my bad english i am not from english countries.

1 answer

while GameStart == true do
    TimerMessage = Instance.new("Hint", game.Workspace)
    TimerMessage.Text = "This game will end in " ..TimerValue.. " seconds"
    wait(1)
    TimerValue = TimerValue - 1
    TimerMessage:remove()
    if TimerValue == 0 then
    	GameStart = false
    	IsArtist = false
    	TimerValue = 120
    end
end

The problem you were having is you had it underneath the While loop. Loops will continuously run, until told to stop, and the thing stopping your loop was GameStart, and the only time it was changed is underneath the loop.

I put that part of code at the bottom of the loop, so every time it loops it checks to see if TimerValue is == 0, and if it is then it will change GameStart to false, thus stopping the loop, and continuing down the script.

I would suggest for this kind of script to use a For loop, as it would be simpler to countdown, for example something like:

for i = 10, 0, -1 do
	print(i)
end

Would print: 10, 9 , 8, 7, 6, 5, 4, 3, 2, 1, 0, in the Output and it is a lot more effective.

For more on For loops or just any loop in general, check out the Wiki.

If the script still doesn't work, please Edit your question with the script, and any errors in the output.

If it does work, then please be sure to +1 and accept the answer.

  • NinjoOnline

2 comments

0

Thanks NinjoOnline, its works

0

No problem :)

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