Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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. :)

1 comment

0

So that code that you commented pretty much means function(player) ?

This discussion is preserved as it was. New answers, comments, and votes are closed.