Tween Door Script Not Working Properly

Hello, I am trying to make this door script using tweening and so far its been going good. But I’ve encountered this error of the door not opening correctly and instead just dragging it to the fake door.

If anyone can figure this out please put it in the comments thanks

Perhaps post your script(s) when posting a submission in scripting support

script.Parent.Touched:Connect(function(hit)
	if table.find(acceptableOpeners, hit.Parent.Name) then
		
			script.Parent.GateOpen:Play()
		
			local OpenTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = fakeDoor1Position})
			OpenTween1:Play()

			script.Parent.Light.BrickColor = BrickColor.new("Lime green")

			script.Parent.Accepted:Play()
			script.Parent.Accepted.Looped = false

			task.wait(5)
		
			script.Parent.GateClosed:Play()

			local CloseTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = door1Position})
			CloseTween1:Play()

			script.Parent.Light.BrickColor = BrickColor.new("Really red")
			
		end
	end)

Tween their CFrame instead of Position.

What do you mean tween their CFrame?

You are tweening the parts position, but not their orientation. All parts have a CFrame property which is made out of a parts position and various rotational components.

By tweening the CFrame instead of Position you will also be changing orientation, you are not currently.

e.g change {Position = door1Position} to {CFrame = door1CFrame}

It started to give me this error

Your variable door1Position is a Vector3.
Go back in your code to when you assign its value, instead of setting door1Position to something such as Part.Position set it to Part.CFrame

Like this?
image

Oh wait I think I figured it out

Nevermind I it’s still giving me the error.

Can you show the whole script I’m pretty sure door1position = a position value it just has to be the door value so door.CFrame not Doorposition.CFrame

--//Services
local TweenService = game:GetService("TweenService")
local acceptableOpeners = {"LL Keycard", "Keycard", "LI Keycard", "LV Keycard", "LX Keycard", "LO Keycard"}

--//Variables
local Model = script.Parent
local ActualDoor1 = Model.RealDoor
local FakeDoor1 = Model.FakeDoor

--//Controls
local door1Position = ActualDoor1.CFrame
local fakeDoor1Position = FakeDoor1.CFrame
--//Functions
script.Parent.Touched:Connect(function(hit)
	if table.find(acceptableOpeners, hit.Parent.Name) then
		
			script.Parent.GateOpen:Play()
		
			local OpenTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = fakeDoor1Position})
			OpenTween1:Play()

			script.Parent.Light.BrickColor = BrickColor.new("Lime green")

			script.Parent.Accepted:Play()
			script.Parent.Accepted.Looped = false

			task.wait(5)
		
			script.Parent.GateClosed:Play()

			local CloseTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = door1Position})
			CloseTween1:Play()

			script.Parent.Light.BrickColor = BrickColor.new("Really red")
			
		end
	end)

it says Unable to cast to dictionary

--//Services
local TweenService = game:GetService("TweenService")
local acceptableOpeners = {"LL Keycard", "Keycard", "LI Keycard", "LV Keycard", "LX Keycard", "LO Keycard"}

--//Variables
local Model = script.Parent
local ActualDoor1 = Model.RealDoor
local FakeDoor1 = Model.FakeDoor

--//Controls
local door1CFrame = ActualDoor1.CFrame
local fakeDoor1CFrame = FakeDoor1.CFrame
--//Functions
script.Parent.Touched:Connect(function(hit)
	if table.find(acceptableOpeners, hit.Parent.Name) then
		
		Model.GateOpen:Play()
		TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = fakeDoor1CFrame}):Play()
		Model.Light.BrickColor = BrickColor.new("Lime green")
		Model.Accepted:Play()
		Model.Accepted.Looped = false

		task.wait(5)

		script.Parent.GateClosed:Play()
		TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = door1CFrame}):Play()
		Model.Light.BrickColor = BrickColor.new("Really red")
		
	end
end)
2 Likes

Oh yeah I forgot to say make sure to change position to CFrame

1 Like

You could try this:

local TweenService = game:GetService("TweenService")

local door = game.Workspace.Door
local doorPlaceholder = game.Workspace.DoorPlaceholder

local goal = {}
goal.CFrame = doorPlaceholder.CFrame

local openTime = .5
local tweenInfo = TweenInfo.new(openTime)

local tween = TweenService:Create(door, tweenInfo, goal)

tween:Play()

Or if door is a model, set a primary part and weld all other parts to the primary part, then try this one instead:

local TweenService = game:GetService("TweenService")

local door = game.Workspace.Door.PrimaryPart
local doorPlaceholder = game.Workspace.DoorPlaceholder.PrimaryPart

local goal = {}
goal.CFrame = doorPlaceholder.CFrame

local openTime = .5
local tweenInfo = TweenInfo.new(openTime)

local tween = TweenService:Create(door, tweenInfo, goal)

tween:Play()
1 Like

Sorry for the late reply but thanks this worked.