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

Why can't I change the targetangle on a hinge constraint with a script?

Asked by 4 years ago
script.Parent.HingeConstraint.ServoMaxTorque = math.huge
script.Parent.HingeConstraint.AngularSpeed = 0.1


workspace.off.ClickDetector.MouseClick:Connect(function()
    script.Parent.HingeConstraint.TargetAngle = 0
end)

workspace.off.ClickDetector.MouseClick:Connect(function()
    script.Parent.HingeConstraint.TargetAngle = 100
end)

spawn(function()
    while wait() do
        print(script.Parent.HingeConstraint.TargetAngle)
    end
end)

It prints 0 all the time, even when I have clicked on the off part.

1 answer

Log in to vote
1
Answered by 4 years ago

Your problem is simple (I think?), you simply had workspace.off.ClickDetector.MouseClick:Connect(function() for both functions, but I'm assuming you meant to have one of them set to workspace.on instead. So basically, both of those functions were running whenever workspace.off was clicked.

Ad

Answer this question