I was wondering if it’s possible to detect if textbox number input has any decimals on it or not. I tried string.match but it wouldn’t work.
An if statement is preferred.
1 Like
string.find() might work for you
Did that too and still errors.
local t = "this is a.test"
print("Checking: '".. t.. "'")
if string.find(t,".") then
warn('Has a "."')
end

That code above created a bug. This code does work however it has to loop through the entire text
local t = "this is atet"
local hasdot = false
for i=1,string.len(t) do
if string.sub(t,i,i) == "." then
hasdot = true
end
end
if hasdot then
warn("has dot")
else
warn("no dot")
end
Is there text written too, or just numbers?
It’s only numbers, no text involved.
Can you share the code you already tried?
1 Like
Just to this
local text = "2.50"
if tonumber(text) < 0 then
warn("has dot")
else
warn("no dot")
end
1 Like
Then I guess this is it:
local textbox = ... -- put textbox here
if tonumber(textbox.Text) == math.floor(tonumber(textbox.Text)) then
... -- put code here
end
1 Like