# How to wait until touch in a for loop

You can write your topic however you want, but you need to answer these questions:

1. What do you want to achieve? So i want to make a missile,That follow a bezier curve,Which has some part,I want it to use rocket propulsion to get from one part to another vai a for loop

2. What is the issue? I don’t know how to loop through and wait until the missile come close to the proximity of each bezier curve node and i could not use Touched:Wait since,The part may touch anything else,That will delay until the part come close to the bezier node.And i don’t want estimation

``````local b = require(game.ServerScriptService.BezierCurve)
workspace.Util.Point.Position =     b.CalculatePoint(self,Vector3.new(-10.276, -24.264, -1853.351),Vector3.new(-2574.721, -24.264, 782.699),{Vector3.new(-1285.927, 2740.106, -495.585),Vector3.new(-1300, 2740.106, -495.585)},0.25)
local lp = nil
local currentN= 0
local s = Vector3.new(-10.276, -24.264, -1853.351)
local run = game["Run Service"]
for _,pos in pairs(b.Calculate(self,Vector3.new(-10.276, -24.264, -1853.351),Vector3.new(-2574.721, -24.264, 782.699),20,{Vector3.new(-1285.927, 2740.106, -495.585)})) do
local cp = Instance.new("Part")
currentN += 1
cp.Parent = workspace.Util.curveParts
cp.Anchored = true
cp.CanCollide = false
cp.Name = tostring(currentN)
if lp then
cp.Size = Vector3.new(0.2,0.2,(lp-pos).Magnitude)
cp.CFrame = CFrame.new((lp+pos)/2,pos)
else
cp.Size = Vector3.new(0.2,0.2,(s-pos).Magnitude)
cp.CFrame = CFrame.new((s+pos)/2,pos)
end
lp = pos
end

``````
1 Like

If you want to wait before the rocket touches a particular object, you can use an `:IsA()` inside the touched function.

No it wont work since its just checking if the part is something,But if its not its gonna just skip and go through the next part which i dont want.

I don’t think this is the best method, I think you should base it off of proximity. However, I think this will answer your question.

``````local touch
repeat touch = cp.Touched:Wait() until touch.Name == "Node" -- idk how you identify the nodes, identify it after 'until'
``````
2 Likes