I have recently been interested in lua scripting , I understand most of the stuff but I dont understand function parameters.
Like for example while writing functions for a leaderboard:
local function <u> onPlayerJoin(player) </u>
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
<u> leaderstats.Parent = player </u>
end
I have marked the areas where I’m confused by using the HTML <u.> element.
I really don’t understand why it’s been used here neither do I know what it’s used for. I’m looking for a well defined answer that clears my doubt( what are parameters , what are they used for , some other examples of scenarios where they would be used etc.) .
( I do have a good idea on programming in general , so I don’t need an explanation as you would explain to a complete beginner )
I have tried watching Youtube videos , but they dont explain it too well for me to understand.
Parameters are basically placeholders that are passed on with functions in the brackets as show here,
Some functions force a parameter such as game.Players.PlayerAdded:Connect(Function(Player)
As you can tell the forced parameter for the .PlayerAdded function is Player, and that is the player object found in the players folder in the explorer.
now that’s the first type of a parameter passed on the second type can be given out like this
function small(Word)
print(Word)
end
small("Small")