Hi i am doing a drop cash system and i was wondering how could i implement the drop cash left if your cash is lower than the Desired Cash to drop (cashNum), because, let’s say i have 2 money, and i want to drop 20 cash, the cash it will drop just 20, but it isn’t correct, it would drop 2 instead, or in any case, just say “You don’t have that many cash” , how would i do it ?
drop_cash.OnServerEvent:Connect(function(player: Player, cashNum: number)
local character = player.Character
if playerTable[player.Name] then
print(playerTable)
if tick() - playerTable[player.Name] > cooldownTimeDrop then
local leaderstatsFolder = nil
local playerstats = nil
if player:FindFirstChild(Settings["playerstats_Name"]) then
playerstats = player:WaitForChild(Settings["playerstats_Name"]) :: Folder
end
if player:FindFirstChild(Settings["leaderstats_Name"]) then
leaderstatsFolder = player:WaitForChild(Settings["leaderstats_Name"]) :: Folder
end
if leaderstatsFolder and playerstats then
local Cash = playerstats:WaitForChild(Settings["currency_Name"]) :: NumberValue
local StoredCash = playerstats:WaitForChild(Settings["storedcurrency_Name"]) :: NumberValue
if Cash and StoredCash then
if Cash.Value >= 1 then
playerTable[player.Name] = tick()
Cash.Value = Cash.Value
task.wait()
local cashToGive = cashNum
if Cash.Value <= cashToGive then
-- warn(cashNum - Cash.Value)
Cash.Value = 0
elseif Cash.Value >= cashToGive then
Cash.Value -= cashToGive
elseif cashToGive > Cash.Value then
end
local cashclone = cash_template:Clone()
local billboard = cashclone:WaitForChild("BillboardGui")
local amount_text = billboard:WaitForChild("amount")
cashclone.CollisionGroup = "Cash"
local amount = cashclone:WaitForChild("amount") :: NumberValue
local Ownership_plr = cashclone:WaitForChild("Ownership") :: ObjectValue
cashclone.Anchored = true
local modelgroup = Instance.new("Model")
modelgroup.Name = player.Name.."'s ".. "Cash"
cashclone.Parent = modelgroup
Ownership_plr.Value = player
task.wait()
amount.Value = cashToGive
amount_text.Text = tostring(amount.Value.."$")