Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by
Vid_eo 126
8 years ago

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)


0
here we see the random downvotes. HungryJaffer 1246 — 8y
0
ugh, ikr Vid_eo 126 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
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}

0
Wont work :/ Vid_eo 126 — 8y
Ad

Answer this question