local deb = false
script.Parent.Touched:connect(function(h)
if h.Parent:FindFirstChild("Humanoid") then
if deb == true then return end
deb = true
script.Parent.Sound4:Play()
local player = game.Players:GetPlayerFromCharacter(h.Parent)
if player.Character:FindFirstChild("Left Leg") or player.Character:FindFirstChild("Right Leg") then
if player.Character:FindFirstChild("Left Leg") then
player.Character["Left Leg"]:Destroy()
end
if player.Character:FindFirstChild("Right Leg") then
player.Character["Right Leg"]:Destroy()
end
end
elseif player.Character:FindFirstChild("Left Leg") ~= nil and player.Character:FindFirstChild("Right Leg") ~= nil then
if player.Character:FindFirstChild("Torso") then
player.Character.Torso:Destroy()
end
end
deb = false
end)
Touching this brick is supposed to destroy the player's legs. If they touch it again while they don't have any legs, their torso will be destroyed. The part where the legs get destroyed works fine, however for some reason I get an "attempt to index field 'Parent' (a nil value)" when I touch it again.

1 comment
Wait, I misplaced the position of an "end". This error still occurs after fixing that though.