I have a leaderboard that I make all the progress saved. But why the other values are not saves even the other values are saved. Example:
- The player joins the game.
- The player level up to level 3 and receive coins
- The player leaves the game
- The player is rejoins again
- The coins have saved but the level is back to level 1 even the coins have saved. But why it that I have a problem or I have more tables that have saved. The values that I save is Wins,Coins,Loses,Gems,Level,Exp and ExpNeeded. The value of Wins,Coins,Loses and Gems are saved but why the values Level,Exp and ExpNeeded are are not saved.This is my script is like this format.
local DataStore = game:GetService("DataStoreService"):GetDataStore("DataSave") game.Players.PlayerAdded:connect(function(player) local key = "key-"..player.userId local leaderstats = Instance.new("Folder") leaderstats.Name = ("leaderstats") leaderstats.Parent = player local Money = Instance.new("IntValue") Money.Name = ("Money") Money.Value = 0 Money.Parent = leaderstats local Wins = Instance.new("IntValue") Wins.Name = ("Wins") Wins.Value = 0 Wins.Parent = leaderstats local Gems = Instance.new("IntValue") Gems.Name = ("Gems") Gems.Value = 0 Gems.Parent = leaderstats local Loses = Instance.new("IntValue") Loses.Name = ("Loses") Loses.Value = 0 Loses.Parent = leaderstats local Level = Instance.new("IntValue") Level.Name = ("Level") Level.Value = 1 Level.Parent = leaderstats local Exp = Instance.new("IntValue") Exp.Name = ("Exp") Exp.Value = 0 Exp.Parent = leaderstats local ExpNeed = Instance.new("IntValue") ExpNeed.Name = ("ExpNeed") ExpNeed.Value = 100 ExpNeed.Parent = leaderstats local save =DataStore:GetAsync(key) if save then Money.Value = save[1] Wins.Value = save[2] Gems.Value = save[3] Loses.Value = save[4] Level.Value = save[5] Exp.Value = save[6] ExpNeed.Value = save[7] else local load = {Money.Value,Wins.Value,Gems.Value,Loses.Value,Level.Value,Exp.Value,ExpNeed.Value} DataStore:SetAsync(key,load) end end end) end)
game.Players.PlayerRemoving:connect(function(player) local key = "key-"..player.userId local load = {player.leaderstats:FindFirstChild("Money").Value,player.leaderstats:FindFirstChild("Wins").Value,player.leaderstats:FindFirstChild("Gems").Value,player.leaderstats:FindFirstChild("Loses").Value,player.leaderstats:FindFirstChild("Level").Value,player.leaderstats:FindFirstChild("Exp").Value,player.leaderstats:FindFirstChild("ExpNeed").Value} DataStore:SetAsync(key,load)
Can you help or advice me?? Do I have reduce the values so that is not overloaded when saved????

1 comment
Go ahead and check this out, https://developer.roblox.com/articles/Saving-Player-Data