Can you explain these codes?

Assuming Abc is a Instance, yes

We are coding about leaderboard right?So where is the line help we know we are coding about it ?

local abc = Instance.new("Folder")
	abc.Name = "abc"
    abc.Parent = player

Can i do this?if i do this is rihht how the system know we are coding about leaderboard(leaderstats)?

The Roblox engine normally detects if a folder named “leaderstats” is on a Player object, if one exists, it goes through all BaseValues inside the folder that can be turned into a string containing the value and displays it on the player list.

local Players = game:GetService(“Players”) —Gets players

local function onPlayerAdded(player) — When they join
local leaderstats = Instance.new(“Folder”) — Making leaderstats
leaderstats.Name = "leaderstats”
leaderstats.Parent = player — Whenever you get more of a currency it gives you that.

local points = Instance.new("IntValue") — Makes your currency show up
points.Name = "Points" — What you see in the top right bar
points.Value = 0 — How much you start with 
points.Parent = leader stats — Makes everything go to the top bar

end

Players.PlayerAdded:Connect(onPlayerAdded)

Because you name the folder “leaderstats” with the line

leaderboard.Name = "leaderstats"

It is a object inside the game which can have a type and a name.
It will stay a folder but will be called leaderstats.

No you cannot, you must set the name into “leaderstats”

local abc = Instance.new("Folder")
	abc.Name = "leaderstats"
    abc.Parent = player

leaderstats is basically just the name of the top right bar I believe. And doing the code will add things yyou want to it like points.

Why?it just give name ,why it must be like that?

The Roblox engine only accepts “leaderstats”, make a feature request if you don’t want the name to be forced

Oh so that is why the system know we are coding about leaderboard right?

The system knows that we are “coding” about the leaderboard as long a folder named “leaderstats” is inside a “Player” object

1 Like

What did you mean?Can you give me that code to make me understand more?

I mean where is the code make the system know,where is it?Can you give me?Please

I mean where is the code make the system know,where is it?Can you give me?Please

When a player joins the system checks if the player has a leaderstats folder inside the player.
And if they do it adds them to the leaderboard.

local Players = game:GetService("Players")-- The player service
 
local function onPlayerAdded(player)--Using the player the function got from the player added event.
	local leaderstats = Instance.new("Folder")--Makes a folder 
	leaderstats.Name = "leaderstats"--Names it leaderstats so the system knows you want to make a leaderstat
    leaderstats.Parent = player--Put it inside the player so the system can check if the player will be added to the leaderboard
 
	local points = Instance.new("IntValue")--The value which holds integers
	points.Name = "Points"--Name it whatever you want.
	points.Value = 0--Change how many points the player will have at the start
	points.Parent = leaderstats--Put it inside the leaderstat folder so the system can take it and add the points value next to their name
end
	
Players.PlayerAdded:Connect(onPlayerAdded)--Line executes every time a player joins and does the onPlayerAdded function above. It also gives it the player that just joined.
1 Like

I just have a problem create a new leaderstats need any code have the words"leaderstats" right?After 51 post i realize the system know we are coding about it that because the line


leaderstats.Name = "leaderstats"

Right?

Right but it has to be inside the player so it knows which player has the leaderstat.

leaderstats.Parent = player

Wow ,that’s it ,i need it.That because the line leaderstats. Name

Can you give me the usage of the code .Name why it can do that(make the system know)?