There are no errors in the output but when I exit and enter the game again, my stats dont load. the script is a server script inside ServerScriptService. Here is my code:
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CashSaveSystem")
local ds2 = DataStore:GetDataStore("ExperienceSaveSystem")
local ds3 = DataStore:GetDataStore("LevelSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local currency = Instance.new("IntValue",leader)
currency.Name = "Coins"
currency.Value = ds:GetAsync(player.UserId)
ds:SetAsync(player.UserId, currency.Value)
currency.Changed:connect(function()
ds:SetAsync(player.UserId, currency.Value)
end)
local experience = Instance.new("IntValue",leader)
experience.Name = "Exp"
experience.Value = ds2:GetAsync(player.UserId)
ds2:SetAsync(player.UserId, experience.Value)
experience.Changed:connect(function()
ds2:SetAsync(player.UserId, experience.Value)
end)
local experiencelevel = Instance.new("IntValue",leader)
experiencelevel.Name = "Level"
experiencelevel.Value = ds3:GetAsync(player.UserId)
ds3:SetAsync(player.UserId, experiencelevel.Value)
experiencelevel.Changed:connect(function()
ds3:SetAsync(player.UserId, experiencelevel.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Coins.Value)
ds2:SetAsync(player.UserId, player.leaderstats.Exp.Value)
ds3:SetAsync(player.UserId, player.leaderstats.Level.Value)
end)

1 comment
have you tried actually going into the physical game rather than studio, a lot of the times when mine wouldn't load it was because it just wouldn't save inside of studio but worked fine in the actual game