How would I tween a model (PrimaryPart - tweening)?
Alright, I know the method :SetPrimaryPartCFrame()
, and I know how to tween single parts.
What I do not know how to do, is how I would tween an entire model, similarly to doing :SetPrimaryPartCFrame
to a model with a placement system. (What I mean is that I want to tween the entire model)
I have no idea what to do in order to tween the entire model relative to it's PrimaryPart
I have this coding for my single-part tweening:
ntarget is specified as the part I want to tween, earlier in the script.
local TimeForObjectToTweenBack = 0.2 function TweenPart() if ntarget ~= nil then local goal = {} goal.Position = PrevPosition --PrevPosition is also specified earlier in the script, don't worry. :| local tweenInfo = TweenInfo.new(TimeForObjectToTweenBack) local tween = TweenService:Create(ntarget, tweenInfo, goal) tween:Play() wait(TimeForObjectToTweenBack) ntarget = nil end end
Any help is greatly appreciated!
lerp
.local start = part.CFrame local finish = start * CFrame.new(10,10,-5) --idk, numbers for i = 0,1,0.03 do part.CFrame = start:lerp(finish, i) wait() end
So in this example, we're moving from start
to finish
, by percentage i
, and the percentage i
is going from 0 to 1, 0 being 0% and 1 being 100%.
I hope that makes sense.
start:lerp(finish, delta AKA Percent)
As you can tell, it's hard to judge how much time it'll take for the lerp to finish if you use wait
. Honesty, I don't want to explain this, and I don't have to, so here's a link to ScriptGuider's video. He'll explain it.
model:SetPrimaryPartCFrame(start:lerp(finish, percent))