Here is my script:
while true do wait(math.random(2.5, 8.5)) while not script.Parent.Position.Y == 53.5 do script.Parent.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y + 0.5, script.Parent.Position.Z) end wait(math.random(2.5, 8.5)) while not script.Parent.Position.Y == 28.5 do script.Parent.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y - 0.5, script.Parent.Position.Z) end end
Please fix it.
What your problem is that you have multiple while loops. A while loop goes on infinitely unless you use break to stop the loop.The solution to this problem is to include if statements instead of while loops.
math.randomseed(tick()) -- Truly makes randomizers truly random while wait() do -- waits 1/30th of a second then,does the rest wait(math.random(2.5, 8.5)) if not script.Parent.Position.Y == 53.5 do script.Parent.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y + 0.5, script.Parent.Position.Z) end wait(math.random(2.5, 8.5)) if not script.Parent.Position.Y == 28.5 do script.Parent.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y - 0.5, script.Parent.Position.Z) end end