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

What is the value of "player" in (function(player) ??

Asked by 1 year ago

I am quite new to Roblox coding, I understand the fundamentals but I am confused on this. I followed a small YouTube tutorial on making a currency system and I wanted to know the value of "player" or what it means. Here is the current script.

game.Players.PlayerAdded:Connect(function(player) local value = Instance.new("NumberValue", player) value.Name = "Currency" end)

workspace.Baseplate:WaitForChild("Humanoid").ClickDetector.MouseClick:Connect(function(player) player.Currency.Value = player.Currency.Value + 10 if (player.Currency.Value + 10) >= 220 then player.Currency.Value = player.Currency.Value - 10 end

end)

workspace.Baseplate:WaitForChild("Buyitem").ClickDetector.MouseClick:Connect(function(player) if (player.Currency.Value - 50) >= 0 then player.Currency.Value = player.Currency.Value - 50 end end)

1 answer

Log in to vote
0
Answered by 1 year ago

Player just refers to what player did the action. For example, player added (player) will give you the player's name of who just joined the game. The click detector will give you the player's name of who clicked the click detector. :) You can also put:

if player.name == "Krektonix" then 
    --code
end

Just if you want to make something that only a certain player can click/touch. :)

0
So that code that you commented pretty much means function(player) ? therealfantastical 7 — 1y
Ad

Answer this question