I really want to make my saving datastore and all of my values be able to go over the roblox 9.22Qi value limit in 2023. I am making a game called crazy hatching simulator and one of my leaderboard players got stuck at the 9.22qi value. I want a clear way to do it. I have searched on this developer hub and I found some but they where either really confusing or they where outdated. I also want a way to be able to remove currency from this too. maybe a little explanation would be good for me and other people with the same problem.
This is my current datastore
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("HatchingMainiaV3.15")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local Success, Error = pcall(function()
local Data = DS:GetAsync(plr.UserId)
if not (Data == nil) then
local MoneyData = tonumber(Data[1])
local RebirthsData = tonumber(Data[2])
local EggsHatchedData = tonumber(Data[3])
local GemData = tonumber(Data[4])
local TotalCoinsData = tonumber(Data[4])
local LeaderStats = Instance.new("Folder")
LeaderStats.Name = "leaderstats"
LeaderStats.Parent = plr
local Money = Instance.new("NumberValue")
Money.Value = MoneyData
Money.Name = "Coins"
Money.Parent = LeaderStats
if TotalCoinsData then
local TotalCoins = Instance.new("NumberValue")
TotalCoins.Value = TotalCoinsData
TotalCoins.Name = "TotalCoins"
TotalCoins.Parent = plr
else
local TotalCoins = Instance.new("NumberValue")
TotalCoins.Value = 0
TotalCoins.Name = "TotalCoins"
TotalCoins.Parent = plr
end
local EggsHatched = Instance.new("IntValue")
EggsHatched.Value = EggsHatchedData
EggsHatched.Name = "Eggs"
EggsHatched.Parent = LeaderStats
local Rebirths = Instance.new("IntValue")
Rebirths.Value = RebirthsData
Rebirths.Name = "Rebirths"
Rebirths.Parent = LeaderStats
local Gems = Instance.new("NumberValue")
Gems.Value = GemData
Gems.Name = "Gems"
Gems.Parent = LeaderStats
local CoinMulti = Instance.new("NumberValue")
CoinMulti.Value = 0
CoinMulti.Name = "CoinMulti"
CoinMulti.Parent = plr
local GemMulti = Instance.new("NumberValue")
GemMulti.Value = 0
GemMulti.Name = "GemMulti"
GemMulti.Parent = plr
else
local MoneyData = 0
local RebirthsData = 0
local EggsHatchedData = 0
local GemData = 0
local TotalCoinsData = 0
local LeaderStats = Instance.new("Folder")
LeaderStats.Name = "leaderstats"
LeaderStats.Parent = plr
local Money = Instance.new("NumberValue")
Money.Value = MoneyData
Money.Name = "Coins"
Money.Parent = LeaderStats
local TotalCoins = Instance.new("NumberValue")
TotalCoins.Value = TotalCoinsData
TotalCoins.Name = "TotalCoins"
TotalCoins.Parent = plr
local EggsHatched = Instance.new("IntValue")
EggsHatched.Value = EggsHatchedData
EggsHatched.Name = "Eggs"
EggsHatched.Parent = LeaderStats
local Rebirths = Instance.new("IntValue")
Rebirths.Value = RebirthsData
Rebirths.Name = "Rebirths"
Rebirths.Parent = LeaderStats
local Gems = Instance.new("NumberValue")
Gems.Value = GemData
Gems.Name = "Gems"
Gems.Parent = LeaderStats
local CoinMulti = Instance.new("NumberValue")
CoinMulti.Value = 0
CoinMulti.Name = "CoinMulti"
CoinMulti.Parent = plr
local GemMulti = Instance.new("NumberValue")
GemMulti.Value = 0
GemMulti.Name = "GemMulti"
GemMulti.Parent = plr
end
end)
if Error then
warn("Error")
print(Error)
else
warn("Success")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local Success, Error = pcall(function()
local SavingTable = {}
table.insert(SavingTable, plr.leaderstats.Coins.Value)
table.insert(SavingTable, plr.leaderstats.Rebirths.Value)
table.insert(SavingTable, plr.leaderstats.Eggs.Value)
table.insert(SavingTable, plr.leaderstats.Gems.Value)
table.insert(SavingTable, plr.TotalCoins.Value)
DS:SetAsync(plr.UserId, SavingTable)
end)
if Error then
warn("Error")
print(Error)
else
warn("Success")
end
end)
game:BindToClose(function()
for i,plr in pairs(game.Players:GetChildren()) do
local Success, Error = pcall(function()
local SavingTable = {}
table.insert(SavingTable, plr.leaderstats.Coins.Value)
table.insert(SavingTable, plr.leaderstats.Rebirths.Value)
table.insert(SavingTable, plr.leaderstats.Eggs.Value)
table.insert(SavingTable, plr.leaderstats.Gems.Value)
table.insert(SavingTable, plr.TotalCoins.Value)
DS:SetAsync(plr.UserId, SavingTable)
end)
if Error then
warn("Error")
print(Error)
else
warn("Success")
end
end
end)
while true do
wait(45)
for i,plr in pairs(game.Players:GetChildren()) do
local Success, Error = pcall(function()
local SavingTable = {}
if plr.leaderstats.Coins.Value >= 0 then
table.insert(SavingTable, plr.leaderstats.Coins.Value)
table.insert(SavingTable, plr.leaderstats.Rebirths.Value)
table.insert(SavingTable, plr.leaderstats.Eggs.Value)
table.insert(SavingTable, plr.leaderstats.Gems.Value)
table.insert(SavingTable, plr.TotalCoins.Value)
DS:SetAsync(plr.UserId, SavingTable)
end
end)
if Error then
warn("Error")
print(Error)
else
warn("Success")
end
end
end