Okay, so we need to use DataStoreService and then :GetDataStore
We get a key for each player by using :GetAsync(player.UserId), which gets the player data when they join.
When a player leaves we save their data with :SetAsync(player.UserId, value)
If you want to go the extra mile you can make sure when roblox errors that player data isn’t lost with pcalls
So your script should look something like this when you are done:
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("IReallyLikeMoney")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new(“Folder”,player)
folder.Name = “leaderstats”
local currency1 = Instance.new(“IntValue”)
currency1.Name = “Money”
currency1.Parent = folder
currency1.Value = DS:GetAsync(player.UserId) or 0
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
local tag = character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
currency1.Value = currency1.Value + 10
end
end
end)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
DS:SetAsync(player.UserId, player.leaderstats.Money.Value)
end)
game:BindToClose(function()
for _,v in pairs(game.Players:GetPlayers())do
DS:SetAsync(v.UserId, v.leaderstats.Money.Value)
end
end)
Let me know if you have any questions!