Door close tween is acting weird

I’m trying to make a door tween script and everything is working expect for the door close tween is tweening weird

Video:

Code:

local Collection = game:GetService("CollectionService")

local Doors = Collection:GetTagged("Doors")

local Tween = game:GetService("TweenService")

local doortweeninfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0)


local function setupdoors(DoorModel)
	local ClosedValue = DoorModel:WaitForChild("Closed")
	local OpenedValue = DoorModel:WaitForChild("Opened")
	local Prompt = Instance.new("ProximityPrompt")
	Prompt.Name = "Prompt"
	Prompt.Parent = DoorModel
	Prompt.ObjectText = "Door"
	Prompt.ActionText = "Open"
	Prompt.ClickablePrompt = false
	Prompt.KeyboardKeyCode = Enum.KeyCode.F
	
	local Table1 = {CFrame = CFrame.new(OpenedValue.Value)}
	local Table2 = {CFrame = CFrame.new(ClosedValue.Value)}
	
	local OpenTween = Tween:Create(DoorModel,doortweeninfo,Table1)
	local ClosedTween = Tween:Create(DoorModel,doortweeninfo,Table2)
	
	Prompt.Triggered:Connect(function()
		if DoorModel:GetAttribute("Opened") == false then
			DoorModel:SetAttribute("Opened",true)
			OpenTween:Play()
		elseif DoorModel:GetAttribute("Opened") == true then
			DoorModel:SetAttribute("Opened",false)
			ClosedTween:Play()
		end
	end)
end




for i, v in pairs(Doors) do
	setupdoors(v)
end

local function newdoors(Door)
	setupdoors(Door)
end

Collection:GetInstanceAddedSignal("Doors"):Connect(newdoors)
1 Like

ClosedValue.Value CFrame doesn’t change the orientation of the door

Try this, it should work. Just make sure to replace the CFrame values.

local Collection = game:GetService("CollectionService")
local Doors = Collection:GetTagged("Doors")

local Tween = game:GetService("TweenService")

local doortweeninfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, 0, false, 0)

local function setupdoors(DoorModel)
	local IsOpen = false
	local ClosedValue = CFrame.new(29, 0.5, 9)
	local OpenedValue = CFrame.new(16, 0.5, 9, 0.49999997, 0, 0.866025448, 0, 1, 0, -0.866025448, 0, 0.49999997)
	local Prompt = Instance.new("ProximityPrompt")
	Prompt.Name = "Prompt"
	Prompt.Parent = DoorModel
	Prompt.ObjectText = "Door"
	Prompt.ActionText = "Open"
	Prompt.ClickablePrompt = false
	Prompt.KeyboardKeyCode = Enum.KeyCode.F
	
	local OpenTween = Tween:Create(DoorModel, doortweeninfo, {CFrame = OpenedValue})
	local ClosedTween = Tween:Create(DoorModel, doortweeninfo, {CFrame = ClosedValue})
	
	Prompt.Triggered:Connect(function()
		if IsOpen == false then
			IsOpen = true
			OpenTween:Play()
		elseif IsOpen == true then
			IsOpen = false
			ClosedTween:Play()
		end
	end)
end

for i, v in pairs(Doors) do
	setupdoors(v)
end

Collection:GetInstanceAddedSignal("Doors"):Connect(setupdoors)