I need help with a problem I’m having with my in-game wallet code. I recently implemented a system in which, when withdrawing money from my weight counter (leaderstats), through a graphical interface that is activated when equipping the wallet, the money is transformed into a tool similar to those of ‘Da Hood’, that is to say to a money tool and that money tool remains in the hands of the player. However, when another player clicks the click detector inside the money tool, the money is not added to their leaderstats.
local script en DineritoUI ( Frame where the amount of money to be withdrawn is written)
local WalletRemotes = game:GetService("ReplicatedStorage"):WaitForChild("WalletRemotes")
local FireMoney = game:GetService("ReplicatedStorage"):WaitForChild("FireMoney")
local frame = script.Parent
local background = frame.Parent
WalletRemotes:WaitForChild("ToggleGui").Event:Connect(function(val)
background.Visible = val
end)
local deb = true
local cooldown = 2
frame:WaitForChild("DropButton").Activated:Connect(function()
FireMoney:FireServer()
if deb then
deb = false
WalletRemotes:WaitForChild("DropCash"):FireServer(frame:WaitForChild("Amount").Text)
task.wait(cooldown)
deb = true
else
frame:WaitForChild("DropButton").Text = "Espera..."
task.wait(0.4)
frame:WaitForChild("DropButton").Text = "Soltar Dinero"
end
end)
Wallet Handler in serverscript service
function abbrevate(amount)
if amount >= 10^6 then
return string.format("%.2fm", amount / 10^6)
elseif amount >= 10^3 then
return string.format("%.2fk", amount / 10^3)
else
return tostring(amount)
end
end
WalletRemotes:WaitForChild("DropCash").OnServerEvent:Connect(function(plr, text)
local amount = tonumber(text)
if amount ~= nil then
local wallet = plr.Character:FindFirstChild("Billetera")
if wallet and wallet:IsA("Tool") and amount >= 100 then
local cash = plr:WaitForChild("leaderstats"):WaitForChild("Pesos")
if cash.Value >= amount then
cash.Value -= amount
local money = script:WaitForChild("Plata"):Clone()
money:SetAttribute("Amount", 0.7 * amount)
money:FindFirstChildWhichIsA("TextLabel", true).Text = "$" .. abbrevate(0.7 * amount)
money.Parent = plr.Backpack
end
end
end
end)
And this is the money pick up in the money tool
local Money = script.Parent
local Tool = script.Parent.Parent
local conn
conn = Money:WaitForChild("ClickDetector").MouseClick:Connect(function(plr)
local pesos = plr:WaitForChild("leaderstats"):WaitForChild("Pesos")
local amount = Money:GetAttribute("Amount")
pesos.Value = pesos.Value + amount
script:WaitForChild("Cash"):Play()
local remote = game:GetService("ReplicatedStorage"):WaitForChild("WalletRemotes"):WaitForChild("PlayerGotCash")
remote:FireClient(plr, amount)
conn:Disconnect()
Money.Transparency = 1
local billboardGui = Money:FindFirstChildOfClass("BillboardGui")
if billboardGui then
billboardGui:Destroy()
end
Tool:Destroy()
for i,v in pairs(Money:GetChildren()) do
if v:IsA("Decal") then
v.Transparency = 1
end
end
local walletRemotes = game.ReplicatedStorage.WalletRemotes
local playerGotCashRemote = walletRemotes:WaitForChild("PlayerGotCash")
playerGotCashRemote:FireClient(plr, amount)
task.wait(1)
conn:Disconnect()
Money:Destroy()
end)
I will apreciate a lot your help!