Hello, I’m stumped by as to why this script works:
local function onPlayerAdded(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
end
Players.PlayerAdded:Connect(onPlayerAdded)
I don’t understand why the “player” parameter for the onPlayerAdded function is used after because it isn’t defined when the function is called. Is it built in?
player is a return of PlayerAdded, when the event is called, it returns the player who joined the game. The name of the parameter doesn’t have to be player, you could name it plr and it would still work after changing soem of the code around