TweenService on a model?

So I am making a door sliding system like a supermarket would have.

Picture here

Here is my current set up

Another photo here

Inside the module, I create the tween movements and send them back, and play the tweens in the Touched script. Am I doing anything wrong in the module?

Module Tween Script
local Doormodule = {}
local Door1 = script.Parent.Door1.PrimaryPart
local Door2 = script.Parent.Door2.PrimaryPart
local TweenService = game:GetService("TweenService")
	
function Doormodule.DoorClose()
	
	local Door1goal = {}
	Door1goal.CFrame = CFrame.new(-12.8892326, 4.28804588, 62.0518227, 0, 0, 1, 0, 1, -0, -1, 0, 0)
	local Door2goal = {}
	Door2goal.CFrame = CFrame.new(-12.8892326, 4.25794125, 66.4844589, 0, 0, 1, 0, 1, -0, -1, 0, 0)
	 
	
	local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false)

	local tween1 = TweenService:Create(Door1, tweenInfo, Door1goal)
	local tween2 = TweenService:Create(Door2, tweenInfo, Door2goal)
	 
	return {tween1, tween2}
end

Thanks, Bylocks!

2 Likes

Unfortunately the TweenService will only touch individual instances. And to move a model, you can’t just set the primary part’s CFrame. Instead, you have to go through the SetPrimaryPartCFrame() method on the model, which will move all the other parts relative to the primary part for you.

Personally I use a custom Tween object that I created, which lets me pass a callback function, which allows me to do custom tweens.

2 Likes

Please do beware of using SetPrimaryPartCFrame for things like tweening, as it can cause your model to break apart with noticable gaps.

However, it’s not quite relevant if you don’t have any rotations involved :slightly_smiling_face:

There is a method in this thread that allows you to do something similar

2 Likes

I’ve made an animation system before that’ll tween groups of parts. All I did was just have a function loop through and find all the parts in the model and tween them individually. Still did it all at once, or, seemingly.