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

How to cframe a model? Move a model with a for loop.

Asked by 6 years ago

Hello,

I would like to know if anyone could help me. I have a model that I want to Cframe to another bricks position. I want it to have a tween but not use tween service. I know I have to use PrimaryPart.

Thanks, Anthony

0
I think the line you are looking for is something like [ for i = 0,1,0.1 do Model:SetPrimaryPartCFrame(ModelStartPosition:Lerp(ModelEndPosition, i)) wait() end ]. Respond if you'd like a detailed explanation Bellyrium 310 — 6y
0
Yes, please. MisterThackeryBinx 29 — 6y

1 answer

Log in to vote
0
Answered by
Bellyrium 310 Moderation Voter
6 years ago

I'll explain here to help make it clear.

local StartPos = Model.PrimaryPart.CFrame --- this is where the model started 
local EndPos = StartPos + Vector3.new(5,10,0) -- this is where the model started moved up and over
for i = 0,1,0.1 do -- this says repeat between 0 and 1 for 0.1. So it will repeat 10 times. 0, 0.1 ,0.2... ect
Model:SetPrimaryPartCFrame(StartPos:Lerp(EndPos, i)) -- this returns a positiong between StartPos and EndPos. I is the increment between. So if i == 0.5 it will be the middle, i == 1 it will be the end i == 0 its the start
wait() 
end
Ad

Answer this question