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

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

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

✓ Accepted answer

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.

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