Well, one of two things is going on here:
#TextBox.Text is 0, meaning there is nothing in the TextBox.
The Text in the TextBox contains something that cannot be converted to a number.
If there is a whitespace character, you can verify this by looping through the string, while using sub() to identify each character:
for i = 1, #script.Parent.Text do
if script.Parent.Text:sub(i, i):find("%s") then
print("Found a whitespace at position " .. tostring(i))
continue
end
end
If it does print, that means #script.Parent.Text is greater than the assumed length if Text was only supposed to contain the number.
If this is not the case, and you have another foreign character, that character should be visible within the TextBox. You can remove the character with ease and move on.
If neither of the above are correct, it means your TextBox's Text is empty. You'll need to fill the text field with a number, and only a number.
7 comments
This is for a textbox btw
The text is empty.
what?
The error. Did you read it?
You are converting a nil value to a number(which is impossible). You'll need to check if your textbox has a value that is not nil.
is this a local or server script?
local