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
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.
I tried put print("b") outside if statement but that still doesn't work. There is no "b" in the output. why? At least it touch baseplate.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
well what do u want to make
Make sure you actually touch the part. Also make sure receptor.CanTouch = true.
@imKirda CanCollide doesn't need to be enabled or disabled.