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.
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)
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)