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?

1local 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.

01local tweenService = game:GetService("TweenService")
02local info = TweenInfo.new()
03 
04local function tweenModel(model, CF)
05    local CFrameValue = Instance.new("CFrameValue")
06    CFrameValue.Value = model:GetPrimaryPartCFrame()
07 
08    CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
09        model:SetPrimaryPartCFrame(CFrameValue.Value)
10    end)
11 
12    local tween = tweenService:Create(CFrameValue, info, {Value = CF})
13    tween:Play()
14 
15    tween.Completed:Connect(function()
16        CFrameValue:Destroy()
17    end)
18end
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