Help on Tween Service

So i’m making a swinging door and it opens smoothly.
But when I try to close it doesn’t.

Here is the script

local openDoor = script.Parent.Parent.Parent.DoorOpen
local closeDoor = script.Parent.Parent
local debounce = false

local tweenService = game:GetService("TweenService")

local DoorTweenInfo = TweenInfo.new(
						1,
						Enum.EasingStyle.Bounce,
						Enum.EasingDirection.Out,
						0,
						false)

local openDoorTween = tweenService:Create(closeDoor, DoorTweenInfo, {CFrame = openDoor.CFrame})		
local closeDoorTween = tweenService:Create(openDoor, DoorTweenInfo, {CFrame = closeDoor.CFrame})

if script.Parent.Parent.Name == "CloseDoor" then
	script.Parent.MouseClick:Connect(function() 
		openDoorTween:Play()
		script.Parent.Parent.Name = "OpenDoor"
end)
	
elseif script.Parent.Parents.Name == "OpenDoor" then
	script.Parent.MouseClick:Connect(function()
		closeDoorTween:Play()
		script.Parent.Parent.Name = "CloseDoor"
	end)
	
end	

I used to name the Door instead of using debounce because I don’t know much about debounce.

Here is where the door is located at.

explorer 1
Also the output is not also showing any errors.

Can anyone help? :slightly_frowning_face:

1 Like

I’m not quite getting your description of how it’s lagging. Could you send a video of it opening and closing?

There is no problem with the opening.The animation works smoothly
but the close animation doesn’t work.It is easy to understand :slightly_smiling_face:

So, when you open the door, it opens perfectly fine, and when you close the door, it lags?

1 Like

yes that’s the problem.
30 charss

image

A small spelling mistake you have made.

1 Like

Oh thanks for telling me the error :slightly_smiling_face:
But why didn’t the output show any error? :question: :thinking:

Just something you might consider, TweenService and Lerp make the door go slightly backwards, so their rotations are not perfect. The door goes backwards while turning, and then comes forward again at the end.

if you want a perfect 90º rotation without the door clipping into the wall use a hinge with a servo

Actually I didn’t understand even a thing. :grimacing:
You see i’m not that of a good scripter.

It isn’t working still :frowning:

Error messages can sometimes be really vague.

Remember that you are using if statements. If the first one isn’t met, then the second one will be met since it’s a elseif statement but that is irrelevant in your case.

If the if statement isn’t met, nothing will run.

To be sure, you’ll need to debug and check if they are met.

local openDoor = script.Parent.Parent.Parent.DoorOpen
local closeDoor = script.Parent.Parent
local debounce = false

local tweenService = game:GetService("TweenService")

local DoorTweenInfo = TweenInfo.new(
						1,
						Enum.EasingStyle.Bounce,
						Enum.EasingDirection.Out,
						0,
						false

local openDoorTween = tweenService:Create(closeDoor, DoorTweenInfo, {CFrame = openDoor.CFrame})		
local closeDoorTween = tweenService:Create(openDoor, DoorTweenInfo, {CFrame = closeDoor.CFrame})

if script.Parent.Parent.Name == "CloseDoor" then
    print("If statement 1 has it's condition met and is now running")
	script.Parent.MouseClick:Connect(function() 
		openDoorTween:Play()
		script.Parent.Parent.Name = "OpenDoor"
end)
	
elseif script.Parent.Parents.Name == "OpenDoor" then
        print("If statement 2 has it's condition met and is now running")
	script.Parent.MouseClick:Connect(function()
		closeDoorTween:Play()
		script.Parent.Parent.Name = "CloseDoor"
	end)
	
end	
1 Like

The arguments are completely valid. An array isn’t passed to TweenInfo.new().

1 Like

Oh yes, I forgot. It’s actually an table…