~~~~~~~~~~~~~~~~~ --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
if byteFlag == 2 then if key.KeyCode == Enum.KeyCode.Return then local yByte = script.Parent.Text byteFlag = 3 print(yByte) end end if byteFlag == 3 then script.Parent.Parent.Position.X = script.Parent.Parent.Position.X + xByte script.Parent.Parent.Position.Y = script.Parent.Parent.Position.Y + yByte byteFlag = 0 end if key.KeyCode == Enum.KeyCode.Return and byteFlag == 0 then --Blah blah blah code stuff if string.lower(script.Parent.Text) == "move" then byteFlag = 1 end print("Yikesss") end
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
string1 = "56" string2 = "hello" print(tonumber(string1)) --Will return 56 formatted as a number print(tonumber(string2)) --Will return nil as "hello" cannot be formatted as a number
same thing as that guy.
string = "pie" if not tonumber(string) then print("no numbers!") else print("there is a number in there!") end
output: no numbers!
string = "64 carrots" if not tonumber(string) then print("no numbers!") else print("there is a number in there!") 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:
local string = "String" local number = 1 local boolean = false print(typeof(string)) print(typeof(number)) print(typeof(boolean))
- string
- number
- boolean
Then you can do conditional statements to figure things out;
local Text = "Hello" if typeof(Text) == "string" then print("It's a string") end
Hope this helped!