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

How do I make a brick not kill a specific humanoid?

Hi. I have this script below. However, for whatever reason, it isn't working. Nothing is getting killed at all, and I am very confused. Basically, I want a specific model to not be killed by the script.

function touch(part)
	if part.Parent:FindFirstChild("Humanoid")~=nil then
		if part.Parent.Name ~= "name of thing excluded from kill" then
		hit.Parent:FindFirstChild("Humanoid").Health=0
	end
end
script.Parent.touched:connect(touch)

What did I do wrong?

2 answers

✓ Accepted answer

Hello, there was some confusion about your question but I seemed to have found an answer, inside of the part you want to kill the players and not the boss put in a ServerScript and put the following:

local bosshumanoid = 'Zombie' -- This is just an example

script.Parent.Touched:connect(function(hit)
	local hum = hit.Parent:WaitForChild('Humanoid')
	if hum.Name == bosshumanoid then
		print('This is the boss')
	else
		hum:TakeDamage(100)
	end
end)

I tested it in studio and it worked hopefully this helps you out!

4 comments

0

Doesn't seem to work, for some reason

0

Oof, can you please tell me what happend

0

OHHH, I am dumb. It was a local script. That has been my issue all this time

0

Oh ok, you had me worried for a second there.

because of if part.Parent.Name ~= "name of thing excluded from kill" then it would work as it is looking for a username named name of thing excluded from kill

 script.Parent.Touched:connect(function(part)
 if part.Parent:FindFirstChild("Humanoid") ~= nil then
 part.Parent.Humanoid.Health = 0
 end
end)

12 comments

0

That kills everything though, which I don't want

0

wdym, just one player like when everyone hits it only one person will be affected?

0

No, I want it to not kill a specific model / humanoid. To do that, I have the if part.Parent.Name ~= "name of thing excluded from kill" then so it doesn't kill it.

0

so you want to it do nothing?

0

im comfused on what you want it to do

0

explain it

0

explain it

0

I want it to not kill a specific model / humanoid. I want it to be able to kill the player, but not the "boss" I have.

0

so your saying you want the script to kill an NPC only?

0

the opposite

0

wait hold on, so you want it to kill players but not your boss correct?

0

yes

This discussion is preserved as it was. New answers, comments, and votes are closed.