How can I smoothly tween a model along a path?

I am trying to make a swinging chandelier but my current method just doesnt look good

Heres the path I’m trying to make

Heres what it looks like right now:

I’m just tweening it between two parts but it looks unnatural and weird, does anyone have a solution?

local tws = game:GetService("TweenService")

local cframe = Instance.new("CFrameValue")
cframe.Value = script.Parent.Swing:GetPrimaryPartCFrame()
cframe.Changed:Connect(function(value)
	script.Parent.Swing:SetPrimaryPartCFrame(value)
end)

while true do
	tws:Create(cframe, TweenInfo.new(1.7, Enum.EasingStyle.Sine), {Value = script.Parent.Pos1.CFrame}):Play()
	script.Parent.Swing.Kill.Sound:Play()
	task.wait(2.4)
	tws:Create(cframe, TweenInfo.new(1.7, Enum.EasingStyle.Sine), {Value = script.Parent.Pos2.CFrame}):Play()
	script.Parent.Swing.Kill.Sound:Play()
	task.wait(2.4)
end

Instead of using a wonky workaround the move the model (creating a value to tween and updating position when it changes), weld the whole thing to a main part and tween that main part instead. Make sure everything is unanchored except the main part. The main part should be at the ceiling level. Using this main part, you can rotate the main part and it will create the whole swing motion.

1 Like

just like @hisupermario9 said, I would suggest you using a base part, and tweening its rotation.

  1. Add a cube to the model. move it where you please, and anchor it. Name it “Hinge”.

  2. Select every other part in the model, and weld it to the hinge. You need to hold Ctrl and select the parts one by one, and finally select the hinge last. then head to the Model tab, and under constraints, choose “Weld”
    image
    (press the ‘create’ dropdown)

  3. Make sure that all the parts EXCEPT the hinge are unanchored. that’s the only way the welds will work.

  4. in your rotating script, simply rotate the hinge either on the X or the Z axis. You can achieve this by using CFrame.Angles().

local orig = model.Hinge.CFrame
local InCF = orig * CFrame.Angles(math.rad(45), 0, 0)
local outCF = orig * CFrame.Angles(math.rad(-45), 0, 0) -- make sure you use math.rad()

if you followed correctly, you should have the chandelier working properly. This method can be utilized with many other things, like doors.
Hope I helped you!

3 Likes

Thanks you!! worked perfectly for me

1 Like

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