I don't understand it's role in this code, plz help meh :3. Thx gais. Btw its a kill script...
function die(part)
h = part.Parent:FindFirstChild("Humanoid")
if h~= nil then
h.Health = 0
end
end
script.Parent.Touched:connect(die)
I don't understand it's role in this code, plz help meh :3. Thx gais. Btw its a kill script...
function die(part)
h = part.Parent:FindFirstChild("Humanoid")
if h~= nil then
h.Health = 0
end
end
script.Parent.Touched:connect(die)
The role of the parameter part here is to act as a reference to the output of the Touched event on BasePart.
According to the Official ROBLOX Wiki page about BasePart, the Touched event returns a reference of type Instance to the object that came into contact with the 'host' Part.
It is possible to ignore the values passed by an event, for example:
function Touch() --There are no parameters, so the touched Part reference is 'dropped'
print("Nothing Special")
end
script.Parent.Touched:connect(Touch)
The purpose of a parameter, in this case, is to provide a reference to a Part Instance.
Part is the part that touches the object, and the 2nd line is basically checking if the part has a humanoid.
This discussion is preserved as it was. New answers, comments, and votes are closed.