Touch event not firing?

G’day dear Devforum. I’ve encountered a new problem that seems to blocking me from testing something. My touch event for a part isn’t registering and I don’t know why.

The parts CanTouch property is on the only thing disabled is can collide.
robloxapp-20241223-2209138.wmv (1.6 MB)
Here’s an example to what I’ve been encountering

script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild(“Humanoid”) then
print(hit.Parent.Name)
end
end)

And here’s the code
Although I don’t see any issue with the code nor are there any errors in my output :frowning:

1 Like

try this

script.Parent.Touched:Connect(function(hit)
    if hit and hit.Parent:FindFirstChild("Humanoid") then 
    print(hit.Parent.Name)
    end
end)
1 Like

Is that a script or local script?

It’s a serverscript placed inside of the part

It works! But why? What’s the difference between this and the other code I’ve written?

Is it because it checks if the hit even exists in the first place?

its hit.Parent.Humanoid not hit.Humanoid hit is a part that touched the given instance and script couldnt find Humanoid inside the part that touched because there wasnt any

Oh yeahhh, my mistake it seems like I forgot how hit detection works mb :skull:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.