Some things have “invisible returns” because Roblox already privides it. For example, if the player touched a part, then roblox would have the part that touched it be a return value of the event. So, in brief terms:
Part gets touched, part is the first parameter of the touched event
Other events like PlayerAdded
and PlayerRemoved
have a parameter that gives the Player
instance, becacuse Roblox made it so that when the player leaves, it get’s the leaving player, then fires the event.
How parameters work is as following:
local function Parameters(Parameter1, Parameter2, Parameter3) -- This would be like the touched event
print(Parameter1, Parameter2, Parameter3) -- "a", "b", "c"
end
Parameters("a", "b", "c") -- This part is what Roblox handles, which is invisible, it returns the part it touched
Returning works like this:
local function Return()
return "a", "b", "c"
end
local Parameter1, Parameter2, Parameter3 = Return()
print(Parameter1, Parameter2, Parameter3) -- "a", "b", "c"
If you still don’t understand, then think about it this way, there are 6 people, 3 people are getting stuff, and 3 people are receiving. The giving people give an apple to the receiving people:
G1 -> R3
G2 -> R3
G3 -> R3
That in code would look like:
local function Parameters(Parameter1, Parameter2, Parameter3) -- "Parameter1" is R1, "Parameter2" is R2, "Parameter3" is R3
print(Parameter1, Parameter2, Parameter3) -- "a", "b", "c"
end
Parameters("a", "b", "c") -- "a" is G1, "b", is G2, "c" is G3