Can someone help me with my door system which is complicated for no reason
local Functions = require(game.ServerScriptService.Functions)
-- Services
local CS = game:GetService("CollectionService")
local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TweenService")
-- Interact
local RemoteEvent = RS:WaitForChild("RemoteEvents")
local DoorInteract = RemoteEvent:WaitForChild("DoorInteract")
local DoorInteractDouble = RemoteEvent:WaitForChild("DoorInteractDouble")
-- Store original CFrames
local originalCFrames = {}
-- Prompt
DoorInteract.OnServerEvent:Connect(function(player, doorName, side)
local DoorModel = workspace.Doors:FindFirstChild(doorName)
local Door = DoorModel:WaitForChild("Door")
local Lock = Door.Lock
local Locks = Door.Locks
local DoorSide = side
local Frame = DoorModel.Frame
if not originalCFrames[Door] then originalCFrames[Door] = Door:GetPivot() end
local originalCFrame = originalCFrames[Door]
local targetCFrame = originalCFrame * CFrame.Angles(0, math.rad(-95aaa), 0)
if DoorSide == "L" then
targetCFrame = originalCFrame * CFrame.Angles(0, math.rad(95), 0)
end
if DoorSide == "R" then
targetCFrame = originalCFrame * CFrame.Angles(0, math.rad(-95), 0)
end
local IsOpen = Door.IsOpen
local IsLocked = Door.IsLocked
if Locks.Value == 0 then
IsLocked.Value = false
else
IsLocked.Value = true
end
if IsLocked == false then
if IsOpen.Value == false then
Functions.RotateDoor(Door, targetCFrame, 0.5)
IsOpen.Value = true
else
Functions.RotateDoor(Door, originalCFrame, 0.5)
IsOpen.Value = false
end
end
end)