Script timing out?

So I have this script that keeps timing out, I have never been good with stuff like this and getting it to not time out, any help?

while true do

if script.Parent.Parent.Occupied.Value == true then

script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,.05)

wait()

else

end

end

Do not use a while loop in most cases.

If you’re detecting a value, just use a .Changed event and then change the CFrame when that fires.

occupied.Changed:Connect(function()

    if occupied.Value == true then

        --change CFrame
    
    end

end)
1 Like

There is nothing in the else case. This means that if the value is false, it enters an infinite loop without yielding (waiting).

8 Likes