So I have a function that will fire whenever a part touch something and I want some parameters in it, and how do I do that?
Here's the original script:
function explode(hit, parameter) print(parameter) -- result is nil end script.Parent.Touched:connect(explode)
So how do I give value to that parameter? Do I put a value after the comma like this?
function explode(hit, parameter) print(parameter) -- result is still nil end script.Parent.Touched:connect(explode, "BOOM")
And also, another question, If I don't use functions and make a touch event like this:
script.Parent.Touched:connect(function(hit, parameter) print(hit) -- obviously, the part that touched it print(parameter) -- if I test it now, it will just be nil end)
So the "hit" is the part that touched it, and for the "parameter", how do you even add value to it?
You can do something like this to provide your own parameters along with the given ones:
function onTouched(hit,parameter) print(hit) print(parameter) end script.Parent.Touched:Connect(function(hit) local parameter = "BOOM" onTouched(hit,parameter) end)
See this last example in Usage for 'changing' arguments.