Okay. In my game, i use datastores to fill out the values on the leaderboard. I am using an edited version of the Roblox U "Mad Bloxxer" scripts. (No, its not another murder game. I think we've all had enough of those) First off, here's where I first set up my datastores.
function playeradded(player)
local mydata = datastore:GetAsync(player.userId) or {}
mydata.wins = mydata.wins or 0
mydata.BC = mydata.BC or 0
mydata.hyperlaser = mydata.hyperlaser or 0
playerdata[player.userId] = mydata
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Value = mydata.wins
wins.Parent = leaderstats
local hyperlaser = Instance.new("IntValue")
hyperlaser.Name = "Hyperlaser"
hyperlaser.Value = mydata.hyperlaser
hyperlaser.Parent = player
local BC = Instance.new("IntValue")
BC.Name = "BlitzCreditz"
BC.Value = mydata.BC
BC.Parent = leaderstats
player:WaitForDataReady() -- make sure we aren't looking for leaderstats before they are created
wait(2) -- just in case
local stats2 = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #stats2 do
stats2[i].Value = datastore:GetAsync(stats2[i].Name) or 0
end
end
game.Players.PlayerAdded:connect(playeradded)
for _, player in pairs(game.Players:GetPlayers()) do
playeradded(player)
end
Here is where I award a win to the player if that player won the game (they won the game if they still have 'MatchTag')
function awardwin(players)
if type(players) == type({}) then
for i = 1, #players do
if players[i]:FindFirstChild("MatchTag") then
if players[i]:FindFirstChild("leaderstats") then
if players[i].leaderstats:FindFirstChild("Wins") then
local stat = players[i].leaderstats.Wins
stat.Value = stat.Value + 1
local newstat = players[i].leaderstats:FindFirstChild("Wins")
local key = "User_" .. players[i].userId
datastore:SetAsync(key, function(oldvalue)
local newvalue = oldvalue or 0
newvalue = newvalue + 1
end)
end
end
end
end
end
end
Heres my variables...
local roundtimer = 90
local intermissiontimer = 5
local datastore = game:GetService("DataStoreService"):GetDataStore("playerdata")
local serverstorage = game:GetService("ServerStorage")
local replicatedstorage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local maps = serverstorage:WaitForChild("Maps")
local mapholder = game.Workspace:WaitForChild("MapHolder")
local gear = serverstorage:WaitForChild("Gear")
local statustag = replicatedstorage:WaitForChild("Status")
local timertag = replicatedstorage:WaitForChild("TimerTag")
local Winner = replicatedstorage:WaitForChild("Winner")
local resulttag = replicatedstorage:WaitForChild("result")
local event = replicatedstorage:WaitForChild("RemoteEvent")
local firstrun = true
local playerdata = {}
Finally, here's where its supposed to save the data when the player leaves
game.Players.PlayerRemoving:connect(function(player)
player:WaitForDataReady()
wait(1)
local stats = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #stats do
print(stats[i].Name)
datastore:SetAsync(stats[i].Name, stats[i].Value)
end
end)
Thanks for the help! Please just give me an edited script, not some vague answer with an example. Not that I want to be picky, but I am a very novice scripter, and it's very hard to learn from something so vague. If I wanted vague answers, I'd be using the Wiki ;)

5 comments
I made it on the spot so...
Thank you so much! One quick question, on line 21, how does it know what ds is? I dont see it referenced anywhere else. Is that like myData?
Also, to increase a value on the leaderboard, can I just increase the value on the leaderboard since it
... will save it at the end anyway?
Check the message I sent you.