Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
Raccoonyz 1092 Donator Moderation Voter
4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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!

0
Doesn't seem to work, for some reason Raccoonyz 1092 — 4y
0
Oof, can you please tell me what happend AntoninFearless 622 — 4y
0
OHHH, I am dumb. It was a local script. That has been my issue all this time Raccoonyz 1092 — 4y
0
Oh ok, you had me worried for a second there. AntoninFearless 622 — 4y
Ad
Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
0
That kills everything though, which I don't want Raccoonyz 1092 — 4y
0
wdym, just one player like when everyone hits it only one person will be affected? raid6n 2196 — 4y
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. Raccoonyz 1092 — 4y
0
so you want to it do nothing? raid6n 2196 — 4y
View all comments (8 more)
0
im comfused on what you want it to do raid6n 2196 — 4y
0
explain it raid6n 2196 — 4y
0
explain it raid6n 2196 — 4y
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. Raccoonyz 1092 — 4y
0
so your saying you want the script to kill an NPC only? raid6n 2196 — 4y
0
the opposite Raccoonyz 1092 — 4y
0
wait hold on, so you want it to kill players but not your boss correct? AntoninFearless 622 — 4y
0
yes Raccoonyz 1092 — 4y

Answer this question