Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

what are parameters and what do they do?

Asked by
iznr 0
5 years ago

Its a bit confusing

0
look it up on yt Gameplayer365247v2 1055 — 5y
0
there are better sources than youtube theking48989987 2147 — 5y
0
By the way the following link is a great way to learn about studio and how to use it: https://developer.roblox.com/learn-roblox/all-tutorials#all Fad99 286 — 5y
0
I personally think that lua pil is best for core principles of lua theking48989987 2147 — 5y

2 answers

Log in to vote
0
Answered by
Fad99 286 Moderation Voter
5 years ago
Edited 5 years ago

A parameter is a special instance that a function could have. For example:

local Players = game.Players

Players.PlayerAdded:Connect(function(Player)
print(Player.Name)
end)

In the code above it will print the name of any player that joins the server. The parameter can be named whatever but in the player added event it will always be the player that is added. You can try the script out for yourself if you want to play around with it. Second Example:

local Part = script.Parent

Part.Touched:Connect(funtion(Hit)
Hit.BrickColor = BrickColor.Random()
end)

In the example above Hit is the part that touches the scripts Parent. You can always check if a function has a parameter by looking at the object browser in the view menu.

0
that would be an argument, as opposed to a parameter theking48989987 2147 — 5y
0
oops Fad99 286 — 5y
0
I'm not sure if theking48989987 is correct on that. A parameter is the variable declared in the method's definition (the general/universal instance), whereas an argument is a specific instance that is passed to that method. BlueGrovyle 278 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Below is an example: ``` game.Players.PlayerAdded:Connect(function(player)

``` In the example above, 'player' is the player that joins the game.

If we wanted to use the parameter to print the player's name then we would do the following. ``` game.Players.PlayerAdded:Connect(function(player) print(player.Name)

``` The above script would print the player's name into the output

'player' could also be called plr, it doesn't matter. However remember that we would have to say the following: game.Players.PlayerAdded:Connect(function(plr) print(plr.Name)

0
You forgot the "end)" in those events lmao Mr_Unlucky 1085 — 5y

Answer this question