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

How to change angle of HingeConstraint from a script?

My current HingeConstraint can go from -90 to +90. The door works by walking into it. I followed the guide on https://developer.roblox.com/en-us/onboarding/building-a-hinged-door/1

I'm in the process of writing a script to make the door go back to its original position after a certain amount of time by utilizing HingeConstraint.CurrentAngle

Let's say the current angle is +90 The default angle is 0 Is it as easy as HingeConstraint.CurrentAngle = 0

local door = script.Parent
local hinge = script.Parent.doorWoodPlank.doorWoodBlank.HingeConstraint

local function reset()
	wait(3)
	hinge.CurrentAngle = 0
end

door.doorWoodPlank.doorWoodBlank.Touched:Connect(reset)

Only error message in output:

can't set value - Server - autoCloseDoor:6

Help is appreciated, thank you in advance

1 comment

0

Im really sorry idk :(

1 answer

So it turns out to answer my own question HingeConstraint.CurrentAngle is READABLE only (I was trying to change its value)

1 comment

0

you should change TargetAngle instead

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