attempt to index local 'humanoid' (a nil value)
local removeHealth = false script.Parent.Touched:connect(function(otherPart) local character = otherPart.Parent local humanoid = character:FindFirstChild("Humanoid") if humanoid then removeHealth = true end while removeHealth == true do wait(1) local CurrentHealth = humanoid.Health local HealthToRemove = 12 CurrentHealth = CurrentHealth.Value - HealthToRemove end script.Parent.TouchEnded:connect(function(otherPart) if humanoid then removeHealth = false end end) end)
Any help?
You need to 'end' your script if the toucher is not a humanoid.
if not humanoid then return end elseif humanoid then removeHealth = true end