Spin Script Gets Overworked and has Burnout

Hello! So Im trying to make it so a sign/Icon marker would spin and show the Burger Icon, the script keeps exhausting though, is their a way I can stop a script from burning out?

Should I make a Wait(1) or something?

The Script

while true do
	script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0,1,0)
end

The Error

  18:57:39.354  Hastey, Hastey Delivery! auto-recovery file was created  -  Studio - C:/Users/mrtix/OneDrive/Documents/ROBLOX/AutoSaves
  18:57:51.644  Script timeout: exhausted allowed execution time  -  Server - Script:2
  18:57:51.645  Stack Begin  -  Studio
  18:57:51.646  Script 'Workspace.BurgerSign.Script', Line 2  -  Studio - Script:2
  18:57:51.647  Stack End  -  Studio

Do this:

while true do wait()
	script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0,1,0)
end

Because without wait it is basically running so fast studio can’t comprehend it

2 Likes

All you have to do is add a wait inside of it.

while true do

wait()

script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0,1,0)

end
1 Like

the problem is the code runs so fast that everything just freezes

you need to yield the loop

also that can be shortened into

script.Parent.Orientation += Vector3.new(0,1,0)
1 Like

Just add a wait() lol, burnout will happen pretty easily

If you don’t want unreliable wait time do this

game:GetService("RunService").Stepped:Wait()

I did this and it worked

while true do
    wait(0.01)
	script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0,1,0)
end

Note that wait is unreliable and waits until the task squedualer to be free.

Is better for gameplay objects.

yep, this also helps if you are low on fps