.Touched detects player only

Hello. I’m trying to make a simple script that does something when the part is touched by an entity with a Humanoid in it.

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

whenever the part is touched, it prints only the plr that touched the part, for some reason it doesn’t work on other dummies

Can we see what inside of a Dummy Model?

1 Like

This is how I would find humanoids if it isn’t a player:


script.Parent.hitbox.Touched:Connect(function(hit)
	local human = hit:FindFirstAnchestorWhichIsA("Model"):FindFirstChild("Humanoid")
    if human then
        print("Hit "..human.Parent.Name)
    end
end)
1 Like

This isn’t a bug. The dummy might not have an humanoid.

Please investigate before calling it a bug as you’re post can get flagged.

1 Like

the dummy does have a humanoid
image

image

do you want it to only detect NPC’s, Players or both?

you shall also check if dummy is anchored or not

both, but for some reason it only detects players

it can’t be detected if it’s anchored? or why?
only the humanoidrootpart is anchored

hit.Parent:FindFirstChildWhichIsA("Humanoid")

There’s no problem in the code

The script only detect player and not dummy because maybe there is a space in dummy’s humanoid, that why I recommended use :FindFirstChildWhichIsA("Humanoid")

1 Like

no, it should still work. i have another script for when the player punches


and it works
(its in the same game)

you should still try though or look for minor errors as spaces in object names

Very weird.
When ever the part is touched, try print the parent of the hit to see what model touched the part. If it a dummy model, this might be a studio bug.

3 Likes

https://gyazo.com/33159b035607b266d6aed410cf2fd78e
here’s a recording so you guys can see what’s happening

i was moving it whilst in server mode or whatever it’s called

can you make a new dummy to test it out there’s might be something wrong in the dummy you’re using as test

Check this : BasePart | Roblox Creator Documentation