Hello, I made an ATM script and it shows me, there is a problem when I type,
Why I got this this error? Attempt to perform arithmetic(add) on nil and number, that really help me
What is the Text inside the TextBox?
What you write as long as it is small of your amount
The function “tonumber” will return nil if it can’t cast the first argument to a number, examples below:
print(tonumber("a")) --> nil
print(tonumber({})) --> nil
print(tonumber("1")) --> 1
I tried it that not working
that show me that rn
You set the script.Parent.TextBox.Text to nil by writing:
script.Parent.TextBox.Text = “”
Therefore, you can’t compare it with the operator <=
Just set the text to nil after completing all your operations
Remove the curly braces, since you’re just putting the value inside of a table.
Well in this case, Script.Parent.TextBox.Text is a string, not a number. And script.Parent.Parent.Frame.Cash.Text is an empty textbox (aka nil).
You need to use the tonumber() function and also check if the text in the textbox is a number like this:
if type(tonumber(script.Parent.Parent.Frame.Cash.Text)) ~= “number” then
warn(“You must write a number!”)
end
I think that’s because you’re checking it on a server script but the text has been edited client side.
Use a remote event on the send button to send it to that script.
yea, I did it but that still not working.
I meant the text inside the text button because the server can’t see what the client wrote inside that text box.
Pass the text as an argument through the event to the server and use that.
If you don’t know how then I can help.
Yep, should be fine like that.
Let me know how it works out!
You never used the argument you sent to the server containing the text.
:Connect(function(player,thethingyousent))