Tween Model not working

Hi, I am trying to tween a model in a local script when you click a button and It isn’t working as expected. At first, I tried to tween the model’s primary part by it’s position but that didn’t work. Then, I found a few forums that explained I should use Cframe instead. I did that but it also did not work. Any help?

local TweenService = game:GetService("TweenService")
local MiniMarket = game.Workspace.MiniMarket
local SlidingDoors = MiniMarket.SlidingDoors

local OpenShop = script.Parent

local DoorLeft = SlidingDoors:WaitForChild("DoorLeft")
local DoorRight = SlidingDoors:WaitForChild("DoorRight")


local doorClosedCFrameLeft = DoorLeft.PrimaryPart.CFrame
local doorClosedCFrameRight = DoorRight.PrimaryPart.CFrame

local doorOpenCFrameLeft = CFrame.new(Vector3.new(949.651, 47.303, -3495.736))
local doorOpenCFrameRight = CFrame.new(Vector3.new(941.17, 47.303, -3487.254))

local SlidingSound = script.Parent.Parent.SlidingDoorSound
local DoorChime = script.Parent.Parent.DoorChime

local tweenInfo = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut, 
	0 
)

local function slideDoors()
	local tweenLeft = TweenService:Create(DoorLeft.PrimaryPart, tweenInfo, {CFrame = doorOpenCFrameLeft})
	local tweenRight = TweenService:Create(DoorRight.PrimaryPart, tweenInfo, {CFrame = doorOpenCFrameRight})
	tweenLeft:Play()
	tweenRight:Play()
end

local function closeDoors()
	local tweenLeft = TweenService:Create(DoorLeft.PrimaryPart, tweenInfo, {CFrame = doorClosedCFrameLeft})
	local tweenRight = TweenService:Create(DoorRight.PrimaryPart, tweenInfo, {CFrame = doorClosedCFrameRight})
	tweenLeft:Play()
	tweenRight:Play()
end

OpenShop.MouseButton1Click:Connect(function()
	wait(3)
	DoorChime:Play()
	SlidingSound:Play()
	slideDoors()
	wait(1)
	closeDoors()
	SlidingSound:Play()
	DoorChime:Play()
end)
1 Like

To tween a model, you must tween the primarypart’s CFRAME, The primarypart should be anchored. Every other part in the model must not be anchored, and needs to be welded to the primarypart.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.