Killing NPCs but not players?

Hi,

Basically I am trying to get the same effect as in Clean Up Roblox where you can have 20 person severs. In the game you have the Roblox laser blaster. Now I want this to kill the npc with humanoids, but not the players to kill each other.

How would I go about doing that?

Help is greatly appreciated!

Thanks,
Dxvil

2 Likes
local function Touched(h)
if game.Players:GetPlayerFromCharacter(h.Parent) then return end -- CODE TO DETECT lF PLAYER
--C0DE
end
2 Likes

How would I stop them from dying though?
(Thanks for responding)

1 Like

It checks if the part that was detected is part of a player’s character, if so then exit the function using return
In the case of laser blasters it most likely will be using raycast’s so you can check first if the basepart instance that got hit is the descendant of a model and check if that character model is a player’s character, if so then exit the function.

3 Likes

Your uh, damage cript, before you damage a “humanoid” check if they are a player, and then if they are a player “game.Players:GetPlayerFromCharacter(h.Parent)” stop the code/ dont kill the player,
l would uze return

2 Likes

I wouldn’t know how to do that to be honest. Could you help?

1 Like

You should probably provide the blaster’s script(s).
Are you referring to this gear?

3 Likes

Yes! That is the exact item. I’ll get the script and delete this topic and make a new one.

1 Like

You could just change the name of the enemy’s humanoid (for example “ZHumanoid”) and every time you need to reference an enemy, you could just type:

char:WaitForChild(“ZHumanoid”)

2 Likes

That’s not a bad idea, although this might work I wouldn’t know where or how to do it.

1 Like