Timsaay
(tim)
June 30, 2021, 4:03am
#1
Hello there, recently I learnt about while loops and I made the most simple while loop I could think of.
while john < 5 do
game.Workspace.johnspart.Transparency = 0.6
end
In the output this appeared and my studio almost crashed 13:59:08.012 Script timeout: exhausted allowed execution time - Server - Script:3. How can I use while loops then if it will crash?
1 Like
put wait() or ur studio will crash
everytime u use loop dont forget to put wait()
Timsaay
(tim)
June 30, 2021, 4:05am
#4
where should I put it? please tell me where
u can put inside on the loop thats it
like this
while john < 5 do
wait()
game.Workspace.johnspart.Transparency = 0.6
end
Timsaay
(tim)
June 30, 2021, 4:06am
#7
local john = 1
while john < 5 do
wait(5)
game.Workspace.johnspart.Transparency = 0.6
end
Blockquote this good?
Yes, that’s good. Or you could just make the wait(5) to wait()
1 Like
Timsaay
(tim)
June 30, 2021, 4:08am
#9
Works, thank you for the help! I am still new to scripting so it really helps.
Timsaay
(tim)
June 30, 2021, 4:08am
#10
what happens if you put wait() instead of wait (5)
No problem, we were all beginners at some point.
nope just keep scripting and just post here if u have more problem
Ryuunske
(Ryuunske)
June 30, 2021, 4:09am
#13
The number inside a wait is how many seconds itll wait before continuing.
the studio will not crash and u can just put wait() cuz u dont have to want until 5 second
Timsaay
(tim)
June 30, 2021, 4:10am
#15
I know but he said to put wait() instead of wait (5)
Timsaay
(tim)
June 30, 2021, 4:11am
#16
what happened if you used wait() in other things, for example
game.StarterGui.ScreenGUI.Frame.Visible = true
wait()
game.StarterGui.ScreenGUI.Frame.Visible = true
when u put wait() the value of waiting is 0.3 if u put wait(5) the value of waiting is 5
Timsaay
(tim)
June 30, 2021, 4:13am
#18
Okay thank you, I didn’t realise just putting wait() still waits for 0.3 seconds
1 Like
Just putting wait() doesn’t mean to wait for 0.3. That information is wrong. Just putting wait means the loop will wait for 0.001 seconds and so fourth.
1 Like
heII_ish
(heII_ish)
June 30, 2021, 4:54am
#20
wait()
yields for about 0.03 seconds, not 0.001
3 Likes