Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

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

0

Yes, please.

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.