~~~~~~~~~~~~~~~~~ --I tried local uis = game:GetService("UserInputService") local byteFlag = 0 local xByte = 0 local yByte = 0 uis.InputBegan:Connect(function(key) if byteFlag == 1 then if script.Parent.Text then xByte = script.Parent.Text byteFlag = 2 print(xByte) end end
01 | if byteFlag = = 2 then |
02 | if key.KeyCode = = Enum.KeyCode.Return then |
03 | local yByte = script.Parent.Text |
04 | byteFlag = 3 |
05 | print (yByte) |
06 | end |
07 | end |
08 |
09 | if byteFlag = = 3 then |
10 | script.Parent.Parent.Position.X = script.Parent.Parent.Position.X + xByte |
11 | script.Parent.Parent.Position.Y = script.Parent.Parent.Position.Y + yByte |
12 | byteFlag = 0 |
13 | end |
14 |
15 | if key.KeyCode = = Enum.KeyCode.Return and byteFlag = = 0 then |
end) --Im fairly new to this kinda coding Im tryna make a admin for the game, And I cant get pass this. ~~~~~~~~~~~~~~~~~**** I really need help I tried to search this on the internet but 0 results.
A textbox input will always be a string. You can check to see if the input can be formatted as a number with tonumber, like so
1 | string 1 = "56" |
2 | string 2 = "hello" |
3 |
4 | print ( tonumber (string 1 )) --Will return 56 formatted as a number |
5 | print ( tonumber (string 2 )) --Will return nil as "hello" cannot be formatted as a number |
same thing as that guy.
1 | string = "pie" |
2 | if not tonumber (string) then |
3 |
4 | print ( "no numbers!" ) |
5 | else |
6 | print ( "there is a number in there!" ) |
7 | end |
output: no numbers!
1 | string = "64 carrots" |
2 | if not tonumber (string) then |
3 |
4 | print ( "no numbers!" ) |
5 | else |
6 | print ( "there is a number in there!" ) |
7 | end |
output: "there is a number in there!"
The above methods are a way to figure things out but If I recall correctly, you can use TypeOf
to find the type of value of something like so:
1 | local string = "String" |
2 | local number = 1 |
3 | local boolean = false |
4 |
5 | print (typeof(string)) |
6 | print (typeof(number)) |
7 | print (typeof(boolean)) |
- string
- number
- boolean
Then you can do conditional statements to figure things out;
1 | local Text = "Hello" |
2 |
3 | if typeof(Text) = = "string" then |
4 | print ( "It's a string" ) |
5 | end |
Hope this helped!