How to check whether a character touched or an npc

  1. I want to achieve a simple line of script which checks whether it’s a player or a humanoid touching. I want it to check if the player is non-existent since a player still has a humanoid so I Think it will be confusing if I don’t specify that I don’t want the player to count as a humanoid but as a player.

  2. I have tried the line below but I don’t think it will work. Please help if you know how to do this. It would be highly appreciated.

if game.Players:GetPlayerFromCharacter(hit.Parent) == nil and humanoid then

end

--I don't think this is the right way to check whether it got a player or not. Please help
3 Likes
if hit.Parent:FindFirstChild("Humanoid") and not game.Players:GetPlayerFromCharacter(hit.Parent) then
--npc
else
--player
end

this will work i guess

9 Likes

I will test that, Looks promising.

1 Like

do you mind if I make another topic? I have a very weird bug in my game that I have been trying to fix for 3 days straight and it really frustrated me. It would be great if you could take a look. Thanks!

1 Like

Go ahead and make the topic. You don’t need to ask in an existing thread.

2 Likes

I made the topic. Please go check it out if your currently free. Thanks!

1 Like