When i made a kill block with script, the output executes error that says : 11:28:55.932 - Workspace.Basic traps and power ups tutorial.Trap.Script:7: attempt to index local 'humanoid' (a nil value).
However, the script itself works fine and it does make humanoid health to 0. Can someone help me to know what is the error with this script?
local trapPart = script.Parent
local function onPartTouch(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if ( "humanoid" ) then
-- Set player's health to 0
humanoid.Health = 0
end
end
trapPart.Touched:Connect(onPartTouch)

2 comments
oh so i dont make the the if part to string, but just directly put in as variable?
yes