How to make a 2 way open door

I am making a horror game right now and I am not sure how to make a 2 way open door.
I am trying to make it open the oposite side that the player is.
Here is my script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

local Assets = script.Parent.Assets
local ProximityPromt = Assets:FindFirstChild("DoorKnob").Detector

local Hinges = script.Parent.Hinges
local HingePart = Hinges.HingePart
local MainDoor = script.Parent.Assets.Door


local Remotes = ReplicatedStorage.Remotes
local InteractionTextRemote = Remotes.InteractionText

local DoorSound = script.Parent.Assets.DoorSound

local DoorOpenGoal = { }
DoorOpenGoal.CFrame = HingePart.CFrame * CFrame.Angles(0,math.rad(90),0)

local DoorCloseGoal = { }
DoorCloseGoal.CFrame = HingePart.CFrame * CFrame.Angles(0,0,0)

local Speed = TweenInfo.new(1)

local TweenOpen = TweenService:Create(HingePart,Speed, DoorOpenGoal)
local TweenClose = TweenService:Create(HingePart,Speed, DoorCloseGoal)

--FUNCTIONS
function OPEN_CLOSE_Door()
    --OPENARGUMENT
    
    if ProximityPromt.ActionText == "Open" then
        TweenOpen:Play()
        DoorSound:Play()
        MainDoor.CanCollide = false
        ProximityPromt.Enabled = false
        ProximityPromt.ActionText = "Close"
        TweenOpen.Completed:Connect(function()
            ProximityPromt.Enabled = true
            MainDoor.CanCollide = true
        end)
        return
    end
    --CLOSEARGUMENT
    if ProximityPromt.ActionText == "Close" then
        TweenClose:Play()
        DoorSound:Play()
        MainDoor.CanCollide = false
        ProximityPromt.Enabled = false
        ProximityPromt.ActionText = "Open"
        TweenClose.Completed:Connect(function()
            ProximityPromt.Enabled = true
            MainDoor.CanCollide = true
        end)
        return
    end
end


--PROMT DETECTION
ProximityPromt.Triggered:Connect(function(Owner)
    OPEN_CLOSE_Door()
end)```
1 Like

There are alot of ways to do it. An basic technique would be putting 2 handles on both sides of door, then when player activates the proximity prompt. Check the nearest handle to player rootpart by using magnitude and then open the door accordingly.

I am making it right now thanks for the addvice

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.