How can I make this stop when it reaches a certain speed?

How can I make the object stop spinning when it reaches a certain rotation speed?

local SpinAmount = 0
script.Parent.Triggered:Connect(function()
while wait(0.001) do
		game.Workspace.Stabilizer.CFrame = game.Workspace.Stabilizer.CFrame * CFrame.Angles(SpinAmount, 0, 0)
		SpinAmount = SpinAmount + 0.0001
end
	end)
1 Like
local SpinAmount = 0
local MaxAmount = 10 -- Change this to whatever you want it to stop at

script.Parent.Triggered:Connect(function()
	while true do
		local Delta = task.wait()
		workspace.Stabilizer.CFrame *= CFrame.Angles(SpinAmount, 0, 0)
		SpinAmount += Delta
		
		if SpinAmount >= MaxAmount then break end
	end
end)
2 Likes

Thank you so much! It finally works

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.