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

Is it possible to use SetPrimaryPartCFrame with TweenService?

Asked by 6 years ago

I would like make that my Model moves with TweenService, but is it possible?

local TweenService = game:GetService('TweenService')
0
test it User#19524 175 — 6y
0
@incapaz, If you got nothing smart to say then say nothing, otherwise if i asked the question, it's because i've already tried it. Thanks dude:) NiniBlackJackQc 1562 — 6y

1 answer

Log in to vote
1
Answered by
Azuc 112
6 years ago

You would need to do something along these lines, however keep in mind that using SetPrimaryPartCFrame will cause floating point precision errors over time.

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
0
Do you guys have a way more proper to use the TweenService function to move a model around? if not thanks for your answer!:)) NiniBlackJackQc 1562 — 6y
Ad

Answer this question