I'm trying to make a leaderboard by trying to get the IntValue in each player, but I don't know where to start.
If anyone has any advice, I'd surely appreciate it!
I'm trying to make a leaderboard by trying to get the IntValue in each player, but I don't know where to start.
If anyone has any advice, I'd surely appreciate it!
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
I hope this helped answer your question. If you have any problems ask me.
(EDIT) I forgot to mention that you insert a script inside of serverscriptservice and paste that
another edit! since you wanted your code to coins as a screen gui just put this script inside of a text label
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
local coins = stats:WaitForChild("Coins")
local text = script.Parent
text.Text = "Coins: "..coins.Value
coins("Value"):Connect(function()
text.Text = "Coins: "..coins.Value
end)
if you have any more questions ask me!
Well I can explain throughly so you can understand...
Let’s start with the function() that will run when the player joins the game
game.Players.PlayerAdded:Connect(function(player)
end)
Now let’s reference the Leaderstats , it should look like this
(it is a “Folder” by the way)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
end)
There. , NOW let’s make some money!
Won’t be hard don’t worry!
Cash will not be a Folder but it’s a IntValue
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Value = 0
Cash.Parent = "leaderstats"
end)
Also if you want to change the amount of Cash you have then, change the number of the Value
And now you are finally done! If you need any further help please contact me here. Bye!
This discussion is preserved as it was. New answers, comments, and votes are closed.
7 comments
Thanks! E
Thanks! W
Thanks! Would you know how to put this as a Screen GUI? (Sorry with the previous comments. My computer screwed up.)
I guess mine didn’t matter
can you accept my answer @TheEggsquidzidBoi ?
Oof mine don’t matter :(
Can u upvote mine