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

How would I make this leaderboad have KOs for money and DataStore?

Hi, I'm making a leader board, but how would I make it have KOs for money, and Data Store? Thanks! Here's my current leader board:

game.Players.PlayerAdded:connect(function(player)
	
	local stats = Instance.new('IntValue', player)
	stats.name = 'leaderstats'
	
	local money = Instance.new('IntValue', stats)
	money.Name = 'Money'
	
	money.Value = 0
end)


3 comments

0

here we see the random downvotes.

0

ugh, ikr

1 answer

local ds = game:GetService("DataStoreService"):GetDataStore("Leaderboard")

game.Player.PlayerAdded:connect(function(player)
local tab = ds:GetAsync(player.userId.." Data")
if not tab then tab = {{"Money","IntValue",0},{"AddAnotherValueHere","IntValue",0}} end
local stats = Instance.new("IntValue",player)
stats.Name = "leaderstats"

for i = 1,#tab do
local val = Instance.new(tab[i][2],player)
val.Value = tab[i][3]
val.Name = tab[i][1]
end
end)

Basically in the tab there's tables set up like {"ValueName","ValueType",Value}

1 comment

0

Wont work :/

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