Help with Tweening Door Opening

had a script, its working and printing proper codes as tested but the Tween doesn’t play neither the door plays the tween itself. Can anyone help me out with this one?

local TweenService  = game:GetService("TweenService")
local TweenInf		= TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)

--//
local DoorBase		= script.Parent.DoorBase.DoorBase
local DoorHandle	= script.Parent.DoorHandle
local ClickDetect	= DoorHandle.Click

local DoorToggle	= false

local Goal_Open		= {}
Goal_Open.C0 = CFrame.Angles(0, 90, 0)
Goal_Open.C0 = CFrame.new(0,0, -3)

local Goal_Close		= {}
Goal_Close.C0 = CFrame.Angles(0, -90, 0)
Goal_Close.C0 = CFrame.new(0,0, -3)

ClickDetect.MouseClick:Connect(function()
	if DoorToggle == false then
		print("Door Clicked: Opened")
		print(DoorToggle)
		TweenService:Create(DoorBase, TweenInf, Goal_Open):Play()
		DoorToggle = true
	elseif DoorToggle == true then
		print("Door Clicked: Closed")
		print(DoorToggle)
		TweenService:Create(DoorBase, TweenInf, Goal_Close):Play()
		DoorToggle = false
	end
end)
2 Likes

I don’t think your using TweenService correctly, your changing a property twice in the same tween which I think doesn’t work, try doing something like this:

ClickDetect.MouseClick:Connect(function()
	if DoorToggle == false then
		print("Door Clicked: Opened")
		print(DoorToggle)
		TweenService:Create(DoorBase, TweenInf, {
			C0 = CFrame.Angles(0, 90, 0);
		}):Play()
		TweenService:Create(DoorBase, TweenInf, {
			C0 = CFrame.new(0, 0, -3);
		}):Play()
		DoorToggle = true
	elseif DoorToggle == true then
		print("Door Clicked: Closed")
		print(DoorToggle)
		TweenService:Create(DoorBase, TweenInf, {
			C0 = CFrame.Angles(0, -90, 0);
		}):Play()
		TweenService:Create(DoorBase, TweenInf, {
			C0 = CFrame.new(0, 0, -3);
		}):Play()
		DoorToggle = false
	end
end)
1 Like

still doesn’t work tho… Tried it that way. Here’s the updated script:

ClickDetect.MouseClick:Connect(function()
	if DoorToggle == false then
		print("Door Clicked: Opened")
		print(DoorToggle)
		TweenService:Create(DoorBase, TweenInf, {C0 = CFrame.Angles(0, -90, 0)}):Play()
		TweenService:Create(DoorBase, TweenInf, {C0 = CFrame.new(0,0, -3)}):Play()
		DoorToggle = true
	elseif DoorToggle == true then
		print("Door Clicked: Closed")
		print(DoorToggle)
		TweenService:Create(DoorBase, TweenInf, {C0 = CFrame.Angles(0, 0, 0)}):Play()
		TweenService:Create(DoorBase, TweenInf, {C0 = CFrame.new(0,0, -3)}):Play()
		DoorToggle = false
	end
end)
2 Likes

Are you using motor6D’s to do this?
I think you should tween the CFrame/Position of the door, you can use attachments to make it easy to use.
You can also use Hinge limits I think, I remember using this before to make a realistic door once.

1 Like

I’m using Welds since I have parts in the door that needs to be welded on a part with WeldsConstraint. And I’m using Welds on the Rotating part.

I believe you cannot write to C0 property of Weld. Therefore tweening will not work either, you need to tween the part itself.

2 Likes

did it on the part with welds too. Like- Shouldn’t it be moving with the tween as well when I tweened the parts? That’s what made me question bc I’ve done that before and it didn’t became a problem with me tweening parts with welds.

Could you show the code where you tried tweening parts?

the code is already posted above

Yeah but all of it tweens C0 which is a property of Weld, and we’ve established that C0 cannot be written to. I don’t see code that tweens the position of the part for example.

1 Like

Posted wrong link, here is a solution of a similar problem.

1 Like