Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't the script rotate the part?

I'm trying to make a gate where if you click the wheel, the part would spin in place while the gate opens. The script below is separate from the script that opens the gate.

--Prototype

w = script.Parent.Parent.Wheel_Part
debounce = true

function turn()
	if debounce == true then
		debounce = false
		for i=1,450 do
		w.CFrame = CFrame.fromEulerAnglesXYZ(0,0,-.8)
		wait()
	end
	wait(1)
	for i=1,450 do
		w.CFrame = CFrame.fromEulerAnglesXYZ(0,0,.8)
		wait()
	end
	debounce = true
end
end

script.Parent.ClickDetector.MouseClick:connect(turn)

1 answer

✓ Accepted answer

Please tab your code correctly.

Anyways, your problem is that you're setting it to 0.8 rotation 450 times, every 30th of a second. You're not adding 0.8 rotation every 30th of a second 450 times. Try this:

w.CFrame = w.CFrame * CFrame.Angles(0, 0, 0.8) --fromEulerAnglesXYZ works too, this is just easier to type.

2 comments

0

You do realize that at the second part where I wait(1) I want the wheel to spin back to original position.

0

and also the wheel spins unbelievably fast....

This discussion is preserved as it was. New answers, comments, and votes are closed.