im in a process of making a roblox game. I want to make the water rise and descend again down. I think i did something wrong with coding,(its my second day of coding and i cant find any video on it) im not sure what. So everytime i run roblox after 1st descending and starting of 2nd game, it freezes,water dissapears and it throws a error: Script timeout: exhausted allowed execution time. Here is my code:
wait(21)
t = 17
repeat
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, 1, 0)
wait(2)
until
t == 0
wait(1)
t = 17
repeat
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, -1, 0)
wait(0.5)
until
t == 0
wait(9)
t = 17
while true do
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, 1, 0)
end
wait(2)
while false do
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, -1, 0)
end
Because the code never stops looping here:
This will continue to loop forever. (Well, for as long as
trueistrue. And I can't think of a condition in which it wouldn't be.)Contrast that with your loops above:
In this case the loop explicitly repeats "until
tequals0", and each iteration of the loop bringstone step closer to0.Modify your later loops to have similar structures and conditions. For example:
Note also that this loop will never execute:
Because
falseis nevertrue. Now is a good time to take a step back and consider the logic of what you want these loops to do. Just like with your first two loops, modify your second two loops to indicate how many times they should repeat.