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

Can someone help me with this script?

So, I'm trying to do a banking system. I have the money and the bank GUI working, but this does not seem to work. Can someone help me figure out why it when I insert the value I want to deposit it won't change the text of the Bank Money GUI.

function hi()
	local player = game.Players.LocalPlayer
	bank = player.BankSave.Value
	money = player.MoneySave.Value
	withdraw = script.Parent.Parent.MoneyValue
	withdrawcash = script.Parent.Parent.MoneyValue.Value
	if money >= withdrawcash then
		bank = withdraw.Value+bank
		print("we just deposited some moolah")
		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)

1 answer

Your assignments to bank and money set bank and money to numbers. Because the Value property is just a number.

It does not link the variable bank and the Value of the BankSave value.


Your variable names should be clearer. What you are doing is a deposit, not a withdrawal.

I am not understanding the purpose of your four Value objects, but here is a simplification involving three of different possible names to illustrate how this will work:

function hi()
	local player = game.Players.LocalPlayer

	bank = player.BankSave
	cash = player.MoneySave
	deposit = player.Deposit

	if cash.Value >= deposit.Value then
		bank.Value = bank.Value + deposit.Value
		cash.Value = cash.Value - deposit.Value

		print("we just deposited some moolah")
		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)

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