Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do i use a text from a textbox as a number value(when it's a number of course)?

Asked by
Echtic 128
5 years ago

So i have a textbox inside a gui that has a number 1 inside it by default, i need to be able to use whatever number is in that textbox as a number value that i can compare and add or subtract from other numbers inside various scripts. Any ideas how i could do that?

0
Wait, are you going to use RemoteEvents, if so you could easily fire it to the client or server and use the parameter of your number. TheOnlySmarts 233 — 5y
0
I will be using a remote event to transfer a few values from the client to the server and edit 2 of them in the server Echtic 128 — 5y
0
So how exactly am i supposed to work with those number parameters, if you don't feel like explaining i'd be satisfied with the dev wiki article link too Echtic 128 — 5y
0
I'm not entirely sure if I know what you mean but could you just add an actual numbervalue object with the same value and have the scripts call upon that? Robb12 12 — 5y
0
That value is being changed by the player in that text box, i need to be able to use that, but it cannot recognize that number inside the textbox as a number, it thinks of it as a string value Echtic 128 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

You can get the number as tonumber(TextBox.Text) if it's really just a number. If someone is allowed to type in something that's not a valid number (like their name) tonumber() will give you nil.

Ad

Answer this question