Hello everyone! I have looked but I cannot find anything on how to cap a Datastore2’s amount. I want to cap money at 999 million but it is not working. Please help!
local players = game:GetService("Players")
local DataStore2 = require(1936396537)
players.PlayerAdded:Connect(function(player)
local CashStore = DataStore2("Cash", player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Parent = leaderstats
Cash.Value = 0
local function UpdateClientCurrency(amount)
Cash.Value = amount
end
UpdateClientCurrency(CashStore:Get(0))
CashStore:OnUpdate(UpdateClientCurrency)
end)