01 | player = script.Parent.Parent.Parent.Parent.Parent |
02 | bal = player.bal |
03 | text = script.Parent.Text |
04 | num = tonumber (text) |
05 |
06 | script.Parent.FocusLost:connect( function () |
07 | print (player.Name) |
08 | print (text) |
09 | print (num) |
10 | if player.leaderstats.Cash.Value > = num then |
11 | print (text) |
12 | bal.Value = bal.Value + num |
13 | end |
14 | end ) |
I'm trying to make an ATM, this is for the deposit part. no matter what i put into the textbox, it always prints this:
Player1
0
0
0
and it doesn't add to the bal value. whats worng with this?
You're storing a copy of the .Text
of script.Parent
(A TextBox
, presumably) into the variable text
. What you should do is store the TextBox
itself, so you can get its .Text
later on.
01 | player = script.Parent.Parent.Parent.Parent.Parent |
02 | bal = player.bal |
03 | text = script.Parent |
04 |
05 | script.Parent.FocusLost:connect( function () |
06 | print (player.Name) |
07 | print (text.Text) |
08 | print ( tonumber (text.Text)) |
09 | if player.leaderstats.Cash.Value > = tonumber (text.Text) then |
10 | print (text.Text) |
11 | bal.Value = bal.Value + tonumber (text.Text) |
12 | end |
13 | end ) |