Make animations in welded train

Hello, I am making a train for a game, based on BodyVelocity and BodyForce. The problem is that i want to open the doors with an animation.
I made an animation with CFrame, but when the train is welded, doors don’t open. The trigger (a TextButton) works, because the door sounds still play correctly, so the problem is in the welding.
How can I make the doors stay attached to the train but let them move in the animation?

1 Like

Use TweenService TweenService | Documentation - Roblox Creator Hub

I used Tweening, the problem is that with the train welded, the tween doesn’t work. Here’s the code:

local TweenService = game:GetService("TweenService")

local door = script.Parent.Door
local closePlaceholder = script.Parent.DoorClosed
local closePlaceholderB = script.Parent.DoorClosedB
local openPlaceholder = script.Parent.DoorOpened
local openPlaceholderB = script.Parent.DoorOpenedB

local closeSound = script.Parent.Part.Close
local openSound = script.Parent.Part.Open

local debounce = true
local isOpened = false

local info1 = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local info2 = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local closeProperties = {}
closeProperties.CFrame = closePlaceholder.CFrame

local closePropertiesB = {}
closePropertiesB.CFrame = closePlaceholderB.CFrame

local openProperties = {}
openProperties.CFrame = openPlaceholder.CFrame

local openPropertiesB = {}
openPropertiesB.CFrame = openPlaceholderB.CFrame

local closeTween = game.TweenService:Create(door, info1, closeProperties)
local close2Tween = game.TweenService:Create(door, info2, closePropertiesB)
local openTween = game.TweenService:Create(door, info1, openProperties)
local open2Tween = game.TweenService:Create(door, info2, openPropertiesB)

game.ReplicatedStorage.RemoteEvent1.OnServerEvent:Connect(function()
	if debounce then
		debounce = false
		if not isOpened then
			openSound:Play()
			openTween:Play()
			wait(1)
			open2Tween:Play()
		else
			closeSound:Play()
			wait(2)
			close2Tween:Play()
			wait(1)
			closeTween:Play()
		end
		isOpened = not isOpened
		wait(1)
		debounce = true
	end
end)

Instead of welding the doors, use weld constraints so you can still animate it, or motor6d (I wouldn’t tho in this scenario)

1 Like