Hey guys, I was making a door for my facility game, The door consists of 2 door pieces which slide in opposite directions when opened just like you will see in SCP games, Though when I made this Door2 seems to work fine, But when you open the door for the first time, Door1 flips 180 degrees. The orientation IS defined, I am confused whats going on. Door1 and Door2 are unions.

Edit: I just found out that Door1's orientation are going in negatives for some reason.

local TweenService = game:GetService("TweenService")
local door1 = script.Parent:WaitForChild("Door1")
local door2 = script.Parent:WaitForChild("Door2")
local enabled = true
local tweeningInformation = TweenInfo.new(
	1,    
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)
local door1Open = {CFrame = CFrame.new(-23.2, 4.016, -36.162) * CFrame.Angles(math.rad(door1.Orientation.X),math.rad(door1.Orientation.Y),math.rad(door1.Orientation.Z))}
local door2Open = {CFrame = CFrame.new(-24.41, 4.016, -46.97) * CFrame.Angles(math.rad(door2.Orientation.X),math.rad(door2.Orientation.Y),math.rad(door2.Orientation.Z))}
local door1Close = {CFrame = CFrame.new(-23.2, 4.016, -41.788) * CFrame.Angles(math.rad(door1.Orientation.X),math.rad(door1.Orientation.Y),math.rad(door1.Orientation.Z))}
local door2Close = {CFrame = CFrame.new(-24.41, 4.016, -41.474) * CFrame.Angles(math.rad(door2.Orientation.X),math.rad(door2.Orientation.Y),math.rad(door2.Orientation.Z))}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
local tween2open = TweenService:Create(door2,tweeningInformation,door2Open)
local tween2close = TweenService:Create(door2,tweeningInformation,door2Close)

script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Triggered:Connect(function(hit)
	if script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText == "Open Door" and script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText == "Open Door" and enabled then
        enabled = false
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = false
		script.Parent.KeyCardReader.KeycardSensor.BrickColor = BrickColor.new("Lime green")
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = false
		script.Parent.KeyCardReader2.KeycardSensor.BrickColor = BrickColor.new("Lime green")
		script.Parent["Keycard Accepted"]:Play()
        wait(1)
		script.Parent["SCP Door Open I"]:Play()
		tween1open:Play()
		tween2open:Play()
		wait(2)
		enabled = true
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText = "Close Door"	
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText = "Close Door"	
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = true
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = true
	elseif script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText == "Close Door" and script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText == "Close Door" then
			script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = false
			script.Parent.KeyCardReader.KeycardSensor.BrickColor = BrickColor.new("Really red")
			script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = false
		    script.Parent.KeyCardReader2.KeycardSensor.BrickColor = BrickColor.new("Really red")
		    script.Parent["Keycard Accepted"]:Play()
		    wait(1)
			script.Parent["SCP Door Open I"]:Play()
			tween1close:Play()
			tween2close:Play()
			wait(2)
			enabled = true
			script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText = "Open Door"	
			script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText = "Open Door"	
			script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = true
			script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = true
			end
end)

script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Triggered:Connect(function(hit)
	if script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText == "Open Door" and script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText == "Open Door" and enabled then
		enabled = false
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = false
		script.Parent.KeyCardReader.KeycardSensor.BrickColor = BrickColor.new("Lime green")
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = false
		script.Parent.KeyCardReader2.KeycardSensor.BrickColor = BrickColor.new("Lime green")
		script.Parent["Keycard Accepted"]:Play()
		wait(1)
		script.Parent["SCP Door Open I"]:Play()
		tween1open:Play()
		tween2open:Play()
		wait(2)
		enabled = true
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText = "Close Door"	
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText = "Close Door"	
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = true
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = true
	elseif script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText == "Close Door" and script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText == "Close Door" then
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = false
		script.Parent.KeyCardReader.KeycardSensor.BrickColor = BrickColor.new("Really red")
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = false
		script.Parent.KeyCardReader2.KeycardSensor.BrickColor = BrickColor.new("Really red")
		script.Parent["Keycard Accepted"]:Play()
		wait(1)
		script.Parent["SCP Door Open I"]:Play()
		tween1close:Play()
		tween2close:Play()
		wait(2)
		enabled = true
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.ActionText = "Open Door"	
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.ActionText = "Open Door"	
		script.Parent.KeyCardReader.Body.Attachment.ProximityPrompt.Enabled = true
		script.Parent.KeyCardReader2.Body.Attachment.ProximityPrompt.Enabled = true
	end
end)

2 comments

0

Are the doors moving straight in opposite directions? If they are, why are you messing around with CFrame.Angles?

0

It is because if I do not define the angles the door will go 0, 0, 0 which Is not it's orientation.