Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Bank Deposit not working?

Alright, so I am making a realistic roleplay game and need help with the bank deposit script I will provide you with the script,developer logs,in-game GUI,explorer and the money leaderboard script.

Deposit script:

	player = script.Parent.Parent.Parent.Parent.Parent
	money = player.Money.Value
	bank = player.BankedMoney.Value
	withdraw = script.Parent.Parent.MoneyValue
	withdrawcash = script.Parent.Parent.MoneyValue.Value

function hi()
	if money.Value <= withdrawcash then
		bank.Value = withdraw.Value+bank.Value
		money.Value = money.Value-withdraw.Value
		script.Parent.Parent.Visible = false
		script.Parent.Parent.Parent.Good.Visible = true
	else
		script.Parent.Parent.Visible = false
		script.Parent.Parent.Parent.Error.Visible = true
	end
	
end


script.Parent.MouseButton1Down:connect(hi)

Developer Logs: https://gyazo.com/bd33ac825c6dd45516d82bf97275751a

In-Game GUI: https://gyazo.com/ebcf57ae6c9841d33dc85872f41e598e

Explorer: https://gyazo.com/586a7ea0a170a0aa1c16bfa37bfa2133

Money LeaderBoard Script:

print("Money Leaderboard Working")
game.Players.PlayerAdded:connect(function(np)
	local value = Instance.new("IntValue")
	value.Name = "Money"
	value.Parent = np
	
	local value = Instance.new("IntValue")
	value.Name = "BankedMoney"
	value.Parent = np
end)

If you could also include the problem and explain so that I may learn from my mistakes.

1 answer

✓ Accepted answer

I think it's due to the fact that you didn't add a waitForChild

Try

    player = script.Parent.Parent.Parent.Parent.Parent
    money = player:WaitForChild("Money")
    bank = player.BankedMoney
    withdraw = script.Parent.Parent.MoneyValue
    withdrawcash = script.Parent.Parent.MoneyValue

function hi()
    if money.Value <= withdrawcash.Value then
        bank.Value = withdraw.Value+bank.Value
        money.Value = money.Value-withdraw.Value
        script.Parent.Parent.Visible = false
        script.Parent.Parent.Parent.Good.Visible = true
    else
        script.Parent.Parent.Visible = false
        script.Parent.Parent.Parent.Error.Visible = true
    end
end


script.Parent.MouseButton1Down:connect(hi)

Or to make the script a little better.

player = script.Parent.Parent.Parent.Parent.Parent
money = player:WaitForChild("Money")
bank = player.BankedMoney
withdraw = script.Parent.Parent.MoneyValue
withdrawcash = script.Parent.Parent.MoneyValue

script.Parent.MouseButton1Down:connect(function()
    if money.Value <= withdrawcash.Value then
        bank.Value = withdraw.Value+bank.Value
        money.Value = money.Value-withdraw.Value
        script.Parent.Parent.Visible = false
        script.Parent.Parent.Parent.Good.Visible = true
    else
        script.Parent.Parent.Visible = false
        script.Parent.Parent.Parent.Error.Visible = true
    end
end)

You also had defined value in the definitions, and then also tried to define value in the script, which meant it tried to define the Value of a Value of a Value.

1 comment

0

Did not work I think the problem is Line 8

This discussion is preserved as it was. New answers, comments, and votes are closed.