This script isn't working, it says attempt to call a nil value but not killing.
function onTouched (part) local h = part.Parent:findFirstChild("Humanoid") if(h~=nil)then h.Health = 0 end end
You are getting there but I can see your Mistake, There is no (connection line) to it, this is what I mean:
function onTouched (part) local h = part.Parent:findFirstChild("Humanoid") if(h~=nil)then h.Health = 0 end end script.Parent.Touched:connect(onTouched)
Your problem is that you never connected the function to an event.
To do so then you need to write something called a 'connection line'. Connection lines can either be in the definition of the function or outside. When they're inside, then it's called an Anonymous function
Connection line example; --NOTE: This would only work if the thing you want to touch is the script's parent
function onTouched (part) local h = part.Parent:FindFirstChild("Humanoid") if h then h.Health = 0 end end --[[ This is the connection statement, you tie the wanted function into the wanted event by placing the function name inside of the parenthasi]] script.Parent.Touched:connect(onTouched)
Anonymous function example; --NOTE: This would only work if the thing you want to touch is the script's parent
--[[With anonymous functions, you define the function INSIDE the connection statement, and you don't name the function]] script.Parent.Touched:connect(function(part) local h = part.Parent:FindFirstChild('Humanoid') if h then h.Health = 0 end end) --Remember to place the parenthasi there to end the connection