Just something you might consider, TweenService and Lerp make the door go slightly backwards, so their rotations are not perfect. The door goes backwards while turning, and then comes forward again at the end.
if you want a perfect 90º rotation without the door clipping into the wall use a hinge with a servo
Remember that you are using if statements. If the first one isn’t met, then the second one will be met since it’s a elseif statement but that is irrelevant in your case.
If the if statement isn’t met, nothing will run.
To be sure, you’ll need to debug and check if they are met.
local openDoor = script.Parent.Parent.Parent.DoorOpen
local closeDoor = script.Parent.Parent
local debounce = false
local tweenService = game:GetService("TweenService")
local DoorTweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
0,
false
local openDoorTween = tweenService:Create(closeDoor, DoorTweenInfo, {CFrame = openDoor.CFrame})
local closeDoorTween = tweenService:Create(openDoor, DoorTweenInfo, {CFrame = closeDoor.CFrame})
if script.Parent.Parent.Name == "CloseDoor" then
print("If statement 1 has it's condition met and is now running")
script.Parent.MouseClick:Connect(function()
openDoorTween:Play()
script.Parent.Parent.Name = "OpenDoor"
end)
elseif script.Parent.Parents.Name == "OpenDoor" then
print("If statement 2 has it's condition met and is now running")
script.Parent.MouseClick:Connect(function()
closeDoorTween:Play()
script.Parent.Parent.Name = "CloseDoor"
end)
end