I have a door script i’m making with hinge constraints, and I don’t want the player to be able to push the door open/closed. How can I do this? Heres the script:
local config = require(script.Parent)
local doors = script.Parent.Parent.Doors:GetChildren()
local doorOpen = false
-- Function to open the door
local function openDoor()
for i=1, #doors do
local door = doors[i]
local hinge: HingeConstraint = door.Hinge.HingeConstraint
hinge.LowerAngle = -90
hinge.TargetAngle = config.TargetAngle
hinge.AngularSpeed = config.HingeSpeed
end
doorOpen = true
end
-- Function to close the door
local function closeDoor()
for i=1, #doors do
local door = doors[i]
local hinge: HingeConstraint = door.Hinge.HingeConstraint
hinge.TargetAngle = 0
hinge.AngularSpeed = config.HingeSpeed
hinge.LowerAngle = 0
end
doorOpen = false
end
-- for testing
closeDoor()
wait(10)
openDoor()
wait(10)
closeDoor()