I would like to point out that both part and hit are exactly the same!
Every touched event has one built in parameter. That parameter is equal to the part that hit the brick with the touched event connected to it. Parameters are very similar to variables in the sense that they stand for something. What you name them has absolutely nothing to do with what they equal.
The following pieces of code will behave exactly the same.
function onTouch(part)
print("I got touched by "..part.Name)
end
script.Parent.Touched:connect(onTouch)
=
function whenITouchDisBrick(hit)
print("I got touched by "..hit.Name)
end
script.Parent.Touched:connect(whenITouchDisBrick)
=
function asdfqwer(dufohohae)
print("I got touched by "..dufohohae.Name)
end
script.Parent.Touched:connect(asdfqwer)
These are all exactly the same!
Other than that, MrSmenryBackup is correct. You used an undefined (or nil) variable on line 7. Since you already have a variable for the Humanoid, just use that instead of h.
2 comments
It did not work even if i remove the 3 at one of the end :(
I don't know what you did, It works fine for me.