I’ve been making my own wallet system recently but I have a glitch that I’m having a hard time to fix. I’m a bit lightheaded from thinking from all of the possible fixes so apologies for any mistakes. I tend to only use DevForum as a last resort.
So the glitch is when I drop a negative number amount of cash, e.g: -1000$
It adds the cash back while dropping a negative number of cash (which if the player decides not to pick, can be used as an infinite money glitch) P.S: I had around 2,000$ before dropping
I assume this could be fixed if I can detect whether the value is negative or not, but I’m not entirely sure how I’d implement this.
This if statement checks if the money value is greater than 0, so I’m confused.
Any questions or help will appreciated, thanks!
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Tool = script.Parent
local Handle = Tool.Handle
local MoneyGui = Handle.MoneyGui
local MoneyLabel = MoneyGui.MoneyLabel
local DropMoney = game:GetService("ReplicatedStorage").RemoteEvents.DropMoney
local formatNumber = (function (n)
n = tostring(n)
return n:reverse():gsub("%d%d%d", "%1,"):reverse():gsub("^,", "")
end)
Tool.Equipped:Connect(function()
local Character = Tool.Parent
local Player = Players:GetPlayerFromCharacter(Character)
local Money = Player.Money
MoneyLabel.Text = formatNumber(tostring(Money.Value)).."$"
end)
Tool.Activated:Connect(function()
local Character = Tool.Parent
local Player = Players:GetPlayerFromCharacter(Character)
local Money = Player.Money
DropMoney:FireClient(Player)
end)
DropMoney.OnServerEvent:Connect(function(Player, DropAmount)
print("fired server")
local Money = Player.Money.Value
local Character = Player.Character or Player.CharacterAdded:Wait()
local moneymodules = ServerStorage.MoneyModules
local moneybag_min = 2500
if DropAmount >= moneybag_min and Money > DropAmount and Money > 0 then
-- Moneybag B)
print("moneybag", tostring(DropAmount).."$")
local moneybag = moneymodules.Moneybag:Clone()
moneybag.Parent = workspace
moneybag.Position = Character.HumanoidRootPart.Position + Vector3.new(0,0,-2)
Player.Money.Value -= DropAmount
moneybag.MoneyGui.MoneyLabel.Text = formatNumber(DropAmount).."$"
elseif DropAmount < moneybag_min and Money > DropAmount and Money > 0 then
-- Money
print("money", tostring(DropAmount).."$")
local money = moneymodules.Money:Clone()
money.Parent = workspace
money.Position = Character.HumanoidRootPart.Position + Vector3.new(0,0,-2)
Player.Money.Value -= DropAmount
money.MoneyGui.MoneyLabel.Text = formatNumber(DropAmount).."$"
end
end)