How do I destroy player bodyparts?

How do I destroy a bodypart of a player? For example, the head. I’ve tried using this script:

local player = game:GetService("Players")
local humanoid = player.LocalPlayer.Character
local debounce = false

script.Parent.Touched:Connect(function()
	if not debounce then
		debounce = true
		local character = player.LocalPlayer.Character
		character.Head:Destroy()
		debounce = false
	end
end)

But all it does is throw me an error message saying:

Workspace.Part.Script:2: attempt to index nil with ‘Character’

This wasn’t a problem in another game of mine though. Please help.

Is this is in a server script or a local script.

If it is in a server script, i advise using this:

local debounce = false

script.Parent.Touched:Connect(function(hit)
	if not debounce then
		debounce = true
		local character = game.Players:GetPlayerFromCharacter(hit)
		character.Head:Destroy()
		debounce = false
	end
end)

Why do you want to Destroy head?

Cause I wanna see what happens.

It will end up killing the player, lol, if im correct

1 Like

If remove head from character, just die.

1 Like

Also, You can set Transparency = 0 on your head to make it look like removed head and not die.

I’ve tried using a script and local script. The local script does nothing whereas the script throws the same error

local character should be

local character = hit:FindFirstAncestorWhichIsA("Model)

what you are trying to do is find player from the body part that touched the part

Try this:

local debounce = false

script.Parent.Touched:Connect(function(hit)
	if not debounce then
		debounce = true
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr == nil or plr.Character:FindFirstChild("Head") == nil then return end
		plr.Character.Head:Destroy()
		debounce = false
	end
end)