Why is this tween not working?

I have 2 sliding doors, and they open if a player gets into an area, and close if a player gets out of the area. The doors open fine and the second door closes as well, but the first one doesn’t close no matter what, and there is no error too.

local TeleportPad = game.Workspace.LeaderBoardHouse.Teleporter.TeleportPad
local OpenDetector = game.Workspace.LeaderBoardHouse.Teleporter.OpenDetector
local InPart = game.Workspace.LeaderBoardHouse.Teleporter.InTeleporterPart
local Door1 = game.Workspace.LeaderBoardHouse.Teleporter.GlassDoor1
local GDClosed = game.Workspace.LeaderBoardHouse.Teleporter.GDClosed
local Door2 = game.Workspace.LeaderBoardHouse.Teleporter.GlassDoor2
local TweenService = game:GetService("TweenService")
local GDClosed = game.Workspace.LeaderBoardHouse.Teleporter.GDClosed

local tweeningInformation = TweenInfo.new(
    1,   
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)

local door1goal = {}
door1goal.Orientation = GDClosed.Orientation
door1goal.Position = GDClosed.Position
local tween1Open = TweenService:Create(Door1,tweeningInformation,door1goal)
local door1Open = {CFrame = CFrame.new(-23.196, -3.347, 148.415)}
local door1Close = {CFrame = CFrame.new(-23.196, -3.347, 142.957)} 
local door2Open = {CFrame = CFrame.new(-32.5, -3.322, 139.709)}
local door2Close = {CFrame = CFrame.new(-26.556, -3.322, 139.709)}
local tween1close = TweenService:Create(GDClosed,tweeningInformation,door1Close)
local tween2open = TweenService:Create(Door2,tweeningInformation,door2Open)
local tween2close = TweenService:Create(Door2,tweeningInformation,door2Close)

OpenDetector.Touched:Connect(function(hit)
	local char = hit.Parent
	local humanoid = char:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
	tween1Open:Play()
	tween2open:Play()
	end
end)


OpenDetector.TouchEnded:Connect(function(hit)
	local char = hit.Parent
	local humanoid = char:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
	tween1close:Play()
	tween2close:Play()	
	end
end)

TeleportPad.Touched:Connect(function(hit)
	local char = hit.Parent
	local humanoid = char:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
	tween2close:Play()
	tween1close:Play()
	end	
end)

TeleportPad.Touched:Connect(function(hit)
	local char = hit.Parent
	local humanoid = char:FindFirstChildWhichIsA("Humanoid")
	local Root = char:WaitForChild("HumanoidRootPart")
	if humanoid then
		game.Workspace.LeaderBoardHouse.Teleporter.TeleportPad.LaserCharge:Play()
		wait(6.671)
		game.Workspace.LeaderBoardHouse.Teleporter.TeleportPad.LaserSound:Play()
		Root.Positon = game.Workspace.HouseRoofTeleport.Position
	end
end)

Most of the script is unorganised, and the last bit doesn’t work because i’m new to scripting, but i put all of the script just if it may help.

You may have mistaken for which part you want to tween, so for this scenario, switch “GDClosed” to “Door1” as you’re twinning GDClosed rather than the door:

local tween1close = TweenService:Create(GDClosed,tweeningInformation,door1Close)

to

local tween1close = TweenService:Create(Door1,tweeningInformation,door1Close)

When i do that, The door just gets Orientation set to 0, 0, 0 and bugs out like shown in the picture.

Also, if i just tell the tween to move the door 30 studs to the -x Axis, it also resets the orientation to 0, 0, 0

Since I don’t see that you’ve used Orientation in the code, I’m assuming that it could be CFrame = CFrame.new() - try changing it to Position = Vector3.new() instead.

2 Likes