Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can i make a gun only kill npc's?

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?

7 comments

0

You can set the zombie's humanoid name into something else, and change the gun's to damage that humanoid's name.

0

if not game.Players:GetPlayerFromCharacter(target.Parent) then --do stuff

0

That fails if they hit a random wall

0

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.

0

if otherPart.Parent:IsA("Model") and otherPart.Parent:findFirstChild("Humanoid") and not game.Players:GetPlayerFromCharacter(otherPart.Parent)

1

you could also add something unique inside the zombie that a player wouldn't have and check for it

0

make it not work on a player

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.