I want to save my kills so whenever a player joins back, they have the right amount of wins and loses.
COMMUNITY QUESTION
How do i save my data When it comes to a win/lose leaderboard?
1 answer
##What you need
In order to do what you want, you need to use DataStores.
Create your DataStore using the
GetDataStorefunction ofDataStoreService.You can then save keys and values to your DataStore using the
SetAsyncfunction, and retrieve them using theGetAsyncfunction.You will have to retrieve saved values using a
PlayerAddedevent, and save the desired stat's Value using aPlayerRemovingevent.
###Code
--Creating the DataStore
local ds = game:GetService("DataStoreService"):GetDataStore("statz");
--Loading stats
game.Players.PlayerAdded:Connect(function(plr)
local data = ds:GetAsync(plr.UserId);
if data then
plr:WaitForChild("Kills").Value = data.kills;
plr:WaitForChild("Deaths").Value = data.deaths;
end
end)
--Saving stats
game.Players.PlayerRemoving:Connect(function(plr)
local data = {kills=plr.Kills.Value,deaths=plr.Deaths.Value};
ds:SetAsync(plr.UserId,data);
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Sorry, no requests here. You need to show us the script for your problem.
http://wiki.roblox.com/index.php?title=Saving_Player_Data