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

Why won't the script rotate the part?

Asked by
painzx3 43
10 years ago

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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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.
0
You do realize that at the second part where I wait(1) I want the wheel to spin back to original position. painzx3 43 — 10y
0
and also the wheel spins unbelievably fast.... painzx3 43 — 10y
Ad

Answer this question