Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to donate Cash?

Asked by 8 years ago

Why is this donate cash script not working (Cash is in ServerStorage) toBox is a Button in a gui same about amountBox,..

toBox=script.Parent.ToPlayer
amountBox=script.Parent.amount
plr=script.Parent.Parent.Parent.Parent

script.Parent.Donate.MouseButton1Click:connect(function()
    toName=toBox.Text
    amount=tonumber(amountBox.Text)
    if game.Players:FindFirstChild(toName) then
        ToPlayer=game.Players[toName]
        if plr.ServerStorage.MoneyStorage.Cash.Value>=amount and amount>0 and amount<1001 then
            plr.ServerStorage.MoneyStorage.Cash.Value=plr.ServerStorage.MoneyStorage.Cash.Value-amount
            ToPlayer.ServerStorage.MoneyStorages.Cash.Value=ToPlayer.ServerStorage.MoneyStorage.Cash.Value+amount
        end
    end 
end)

Answer this question