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?
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!
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)