Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

can you tween Models using TweenService?

Asked by
Mr_Pure 129
5 years ago

So recently I was just testing the limits of TweenService and how far you can push it. It wasn't long before I discovered you can't tween whole models(At least I think). If there is anyway you could tween models using TweenService and not lerp I would be curious to see and yes I did try to weld the model together and then tween it using it's primary part. It doesn't work.

0
I also tried tweening them but never worked. cherrythetree 130 — 5y
0
I don't think so. You can only tween each individual part in the model HomieFirePGN 137 — 5y
0
You actually can tween an entire model just by using parts all attached to the primary part with WeldConstraints and just moving the primary part. It's quite hacky, but it works. Mirzadaswag 110 — 5y

1 answer

Log in to vote
1
Answered by
Norbunny 555 Moderation Voter
5 years ago

I'm not gonna take the credit for this code, as I did not write it. This question has been asked on Roblox's Devforums before, and has been answered.

local tweenService = game:GetService("TweenService")
local info = TweenInfo.new()

local function tweenModel(model, CF)
    local CFrameValue = Instance.new("CFrameValue")
    CFrameValue.Value = model:GetPrimaryPartCFrame()

    CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
        model:SetPrimaryPartCFrame(CFrameValue.Value)
    end)

    local tween = tweenService:Create(CFrameValue, info, {Value = CF})
    tween:Play()

    tween.Completed:connect(function()
        CFrameValue:Destroy()
    end)
end

If you would like to check the original post, and support the original programmer, click here

Ad

Answer this question