I want to make a for loop wait for an event to fire before executing the code in it again. In the code block below is basically what I want.
for i,v in pairs(t) do thing:DoTheThing(v) (Wait for event to fire) end
(Note: This isn't the full code, this is only the loop)
In case you're curious or have any alternate solution, this is for pathfinding to a certain location using the pathfinding service.
How would I go about this sort of thing?
Events have a :wait() method which will wait until it fires, then return any parameters.
http://wiki.roblox.com/index.php?title=Event
local Part = workspace.Part local Hit = Part.Touched:wait() print(Hit)
As you've mentioned, you should use it in a loop. The :wait() method does not automatically make a looping occurrence like :connect() does with a function.