How do i make when character touch npc. you die

How do i make when character touch npc , you die
(I didn’t ask how to make the npc follows)

local players = game:GetService("Players")
local npc = workspace:WaitForChild("NPC")

for _, part in pairs(npc:GetDescendants()) do
	if part:IsA("BasePart") then
		part.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("HumanoidRootPart") then
				local player = players:GetPlayerFromCharacter(hit.Parent)
				if player then
					local character = player.Character
					local humanoid = character:WaitForChild("Humanoid")
					humanoid.Health = 0
				end
			end
		end)
	end
end

Make sure “NPC” is correctly referenced in the 2nd line of the script. Also this is a server script.

Doesnt work. Do i need to add the script in the npc?

No, and I did mention you’ll have to correctly reference the NPC.

Make sure “NPC” is correctly referenced in the 2nd line of the script. Also this is a server script.

“Doesnt work”

https://gyazo.com/afcebb05e09fbb52ef87f274ceeed48c

image

I changed “NPC” to “rbadam” because its my character’s name

It needs to be placed inside the workspace not some folder/model inside the workspace. Exactly as the above screenshot shows.

If your model is named “rbadam” then this:
local npc = workspace:WaitForChild("NPC")
Will need to be:
local npc = workspace:WaitForChild("rbadam")

Its working. Thanks !!!

Well i didnt do this but it worked

No problem, glad I could be of assistance.