So, i have these two codes:
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("ChestsSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = player:FindFirstChild("leaderstats")
local Chests = Instance.new("IntValue",leader)
Chests.Name = "Chests"
Chests.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Chests.Value)
Chests.Changed:connect(function()
ds:SetAsync(player.UserId, Chests.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Chests.Value)
end)
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CoinSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Coins = Instance.new("IntValue",leader)
Coins.Name = "Coins"
Coins.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Coins.Value)
Coins.Changed:connect(function()
ds:SetAsync(player.UserId, Coins.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Coins.Value)
end)
and everytime I try testing my game, the Chest stat just disappears and I havent found any solution to that. I have also got 2 output messages: "DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests." and "Chests is not a valid member of Folder." Please, help :c

2 comments
Already tried doing that, it doesn't work. An error pops up and the other stat wont appear. Isn't there a way to make a single script with both stats?
Ok, solved it by re-making the leaderstat script and making a new data-store script! Thanks anyways!