Does anyone know here to make a number that only accept numbers
Example: textbox only accept numbers between [1 - 6] but if player put the number 7 above, it will not accept it
Does anyone know here to make a number that only accept numbers
Example: textbox only accept numbers between [1 - 6] but if player put the number 7 above, it will not accept it
local Numbers = {1,2,3,4,5,6}
local TextBox = -- TextBox Spot
for i,v in pairs(Numbers) do
if TextBox.Text == tostring(v) then
-- stuff
end
or you could also use
if table.find(tostring(Numbers),TextBox.Text) then
print("yes")
end
yo since its 1-6 then why not just check wether the chosen number is smaller then the biggest number and smaller then the smallest number (something like:)
if 6 >= Chosen >= 1 then
-- do something here
end
there is many ways to do it so yeah.
First get the text box and detect for input, check the input Everytime something is typed, then if itβs over 6 then delete it.
Example:
local textBox = script.Parent
textBox:GetPropertyChangedSignal("ContentText"):Connect(function()
local isNum, num = pcall(function()
return tonumber(textBox.ContentText)
end)
if not isNum then return end
if num < 1 or num > 6 then textBox.Text = "" end
end)
for some reason it doesnt work [no errors]
oopsie i forgot to do tostring(v) cuz we need to convert the numbers to a string
or i couldβve just made the table like this local Numbers = {β1β,β2β,β3β,β4β,β5β,β6β} as strings.