Script:
print("a") receptor.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then print("b") Eaten(receptor,hit) end end) print("c")
Output:
a c
If you're expecting Touched
to pass right off the bat and the output to have a, b, and c consecutively, this will never happen with the code you have. Touched
is an RBXScriptSignal
and will only run the code within a connected function if it successfully fires. It does not behave like an if statement nor does it behave like a loop.
With that being said, your output will ALWAYS look like this:
a c b ... -- other b's
Do you want the if to fire immediately after a is printed? You can put the print("c")
after the print("b")
to achieve an output of a, b, and c consecutively, respectively. If you don't, you're stuck with a, c, and then any b's for your output unless you put all 3 prints inside of the function.