Detecting if a part touches the humanoid

Hello, I need help with figuring out how to make it so if a part touches the humanoid the program will ignore it. currently this is what I have:

local function onPartTouched(otherPart)
if otherPart:FindFirstChild(“Humanoid”) then
print(“Hit”)
end
end

For some reason the preformatted text was glitching so this is what I have. I know this syntax won’t run, but this is the best example I could come up with. The problem I would be running into is whenever I try to throw an object and have it detect a surface, all it does is prints hit right when it leaves the hand. I believe this is because the ball is hitting the hand immediately then ending the function. Is there anyway I can ignore if the hand or a body part that is hit right away?

Thanks, SaKa

1 Like

Just make the look out for objects other than humanoids or body parts, then you’ll be fine. Your script is contradicting what you say, though. You said you don’t want it to detect humanoid, yet you still make the function print “hit” when humanoid is hit.

This is just so I can test if the humanoid gets hit, so when I actually get it I can just have it return end. I don’t know how to make a “Look out” necessarily do you have any code you could use as an example?

otherPart on your script is the part that gets hit. So, just do print(otherPart), then you know what object it’s hitting

I see, I noticed I screwed something up in my script that was causing this. I will fix this problem, but thanks for the help! even though it was an extremely basic problem.

1 Like