Tween Script Not working

Hello their users of devforum. I am trying to make a script where if the door detects a keycard has touched it it will open. Although it does kinda work it makes this weird animation,

Video

What I want to achieve: SCP: Site Roleplay from Visceraled

This is my script

–=====================================

local tweenservice = game:GetService("TweenService")

local infotween = TweenInfo.new(2)

--=====================================

local ActualDoor = script.Parent.ActualDoor

local FakeDoor = script.Parent.FakeDoor

local ActualDoor2 = script.Parent.ActualDoor2

local FakeDoor2 = script.Parent.FakeDoor2

ActualDoorCFrame = ActualDoor.CFrame

FakeDoorCFrame = FakeDoor.CFrame

ActualDoorCFrame2 = ActualDoor2.CFrame

FakeDoorCFrame2 = FakeDoor2.CFrame

--=====================================

closedconfig = {}

closedconfig.CFrame = ActualDoorCFrame  
closedconfig2 = {}

closedconfig2.CFrame = ActualDoorCFrame2

openconfig = {}

openconfig.CFrame = FakeDoorCFrame

openconfig2 = {}

openconfig2.CFrame = FakeDoorCFrame2

--=====================================

local closetween = tweenservice:Create(ActualDoor, infotween, closedconfig)

local opentween = tweenservice:Create(ActualDoor, infotween, openconfig)

local closetween2 = tweenservice:Create(ActualDoor2, infotween, closedconfig)

local opentween2 = tweenservice:Create(ActualDoor2, infotween, openconfig)

--=====================================

local dooropened = false

script.Parent.Parent.TouchPart.Touched:Connect(function(hit)

if hit.Parent.Name == "Keycard" then

opentween:Play() --plays opendoor animation

opentween2:Play()

wait(5)

closetween:Play()

closetween2:Play()

end

end)

i think you should anchor the doors

image
already are entire model is anchored

try changing the doors to massless

There are so many unnecessary variables. Could you show me what’s the difference between the fake door and the real one?

The fakedoors are the position of where the real doors go


This invisible block is bassically just where the actual door goes.

One of the FakeDoor variable is located in a wrong place. It’s your work to find out which one

Try this:

--//Services
local TweenService = game:GetService("TweenService")

--//Variables
local Model = script.Parent
local ActualDoor1 = Model.ActualDoor
local ActualDoor2 = Model.ActualDoor2
local FakeDoor1 = Model.FakeDoor
local FakeDoor2 = Model.FakeDoor2

--//Controls
local dooropened = false
local door1Position = ActualDoor1.Position
local door2Position = ActualDoor2.Position
local fakeDoor1Position = FakeDoor1.Position
local fakeDoor2Position = FakeDoor2.Position

--//Functions
Model.Parent.TouchPart.Touched:Connect(function(hit)
	if hit.Parent.Name == "Keycard" then
		local OpenTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(0.2, Enum.EasingStyle.Quint), {Position = fakeDoor1Position})
		OpenTween1:Play()

		local OpenTween2 = TweenService:Create(ActualDoor2, TweenInfo.new(0.2, Enum.EasingStyle.Quint), {Position = fakeDoor2Position})
		OpenTween2:Play()

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

		local CloseTween2 = TweenService:Create(ActualDoor2, TweenInfo.new(0.2, Enum.EasingStyle.Quint), {Position = door2Position})
		CloseTween2:Play()
	end
end)
1 Like

Doesn’t seem to work,

Oops I forgot to delete some things, I edited my post, please try it again.

this seems to be the error. you’re using the config from the first door for the second one.

1 Like