For some reason this script kinda works but it creates “index nil with :FindFirstChild” error every time
This script kills humanoids with a “Plr” Instance in it, if not it will just delete it instead
This is to kill off ‘Invincible’ enemies by pushing them off into the void
( Ex: This enemy when killed it turns into a pile of pushable mass for a while, before it comes back alive the ‘Player’ have to push it off into the void to kill it. The void only sets humanoid health to 0 so the enemy will still turn into its alive form then die and repeat because the pushable mass turns back into the enemy when killed also )
script.Parent.Touched:Connect(function(Hit)
if Hit and Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent:FindFirstChild("Plr") then
Hit.Parent.Humanoid.Health = 0
else
Hit.Parent:Destroy()
end
end)
I’m very new to scripting so I really don’t know how to explain it but any thing helps
local debounce = false
script.Parent.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid") -- Character.Humanoid
local plr = hit.Parent:FindFirstChild("Plr")
if humanoid and debounce == false and plr then --If humanoid exist and debounce is false
debounce = true
humanoid.Health = 0
task.wait(3)
debounce = false
end
end)
"index nil with :FindFirstChild error " refer to an FindFirstChild function that are being called from nil instace(doesn’t exist).
Try using WaitForChild() and naming thing properly.Plus, try to make sure the parent and child path is correct.