I'm making a game, you are supposed to kill the zombies and roleplay and stuff like that.. I don't know how to make a gun.. So i added a random gun in my game. Is there a way i can make the gun kill npc's and not the players?
COMMUNITY QUESTION
Can i make a gun only kill npc's?
1 answer
You need to make a way to make a diffrince between the npc's and the zombies. You can for example rename the Humanoid to something like Zombie. Then when the bullet hits make it check if the name is just "Humanoid" or "Zombie". You can do this using FindFirstChild
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
You can set the zombie's humanoid name into something else, and change the gun's to damage that humanoid's name.
if not game.Players:GetPlayerFromCharacter(target.Parent) then --do stuff
That fails if they hit a random wall
if hit.Parent.Name=="zombie" then do damage. The only downside I can think of this is if the one person who is named zombie joins your game, you can also kill him.
if otherPart.Parent:IsA("Model") and otherPart.Parent:findFirstChild("Humanoid") and not game.Players:GetPlayerFromCharacter(otherPart.Parent)
you could also add something unique inside the zombie that a player wouldn't have and check for it
make it not work on a player