If i were to catch the end of a for loop, would this be right?
Hi! The situation is: I'm lerping a model to move to another part
The problem is: I can't figure out how to stop the for loop when the alpha (defined as i
) of the lerp becomes a certain number.
Here's my code: (Ignore the comments, they aren't important to my problem/question)
01 | local model = script.Parent |
02 | local dest = workspace.Solar_System.ShipReDirect 1. Position |
03 | local reDirect = script.ReDirect |
04 | local StartCF = CFrame.new(model.PrimaryPart.Position,dest) |
06 | local function getRedirect() |
12 | if dest = = workspace.Solar_System.ToChoosePlanet 1. Position then |
13 | reDirect.Value = workspace.Solar_System.ShipReDirect 4 |
14 | StartCF = CFrame.new(model.PrimaryPart.Position,reDirect.Value.Position) |
18 | local EndCF = StartCF - StartCF.p + dest |
22 | model:SetPrimaryPartCFrame(StartCF:lerp(EndCF,i)) |
23 | if script.Parent.PrimaryPart.CFrame = = reDirect.Value.Position then |
24 | StartCF = CFrame.new(model.PrimaryPart.Position,dest) |
26 | model:SetPrimaryPartCFrame(StartCF:lerp(EndCF,i)) |
I'm still working on the code, but if it's a little confusing i can send a picture of the physical thing and/or the Workspace or more explanation/code on it. Don't hesitate to ask please!
Thank you so much! :)