Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Breaking Script Loop when option is untoggled from GUI?

Asked by
h19rry 20
1 year ago

I'm trying to make a lowrider car that bounces when the option is ticked inside of a GUI, problem I'm having is not being able to loop the bouncing part, and then also breaking the loop and resetting the ride height to normal when the option is no longer ticked in the GUI.

    SuspensionSection:NewToggle("Bounce", "Bounce like a lowrider", function(state)
        Variables()
        while state == true do
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.FL.Spring.FreeLength = 2.35
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.FR.Spring.FreeLength = 2.35
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.RL.Spring.FreeLength = 2.35
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.RR.Spring.FreeLength = 2.35
            wait(0.5)
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.FL.Spring.FreeLength = 3
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.FR.Spring.FreeLength = 3
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.RL.Spring.FreeLength = 3
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.RR.Spring.FreeLength = 3
        else
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.FL.Spring.FreeLength = 2.35
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.FR.Spring.FreeLength = 2.35
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.RL.Spring.FreeLength = 2.35
            game:GetService("Workspace")[PlayerName.."Car"].Wheels.RR.Spring.FreeLength = 2.35
        end
    end)

Any help is appreciated, thanks.

Answer this question