Hello! I have a textbox that lets you type in a number, but I don’t want the player to be able to type numbers above 6. This is the script I have so far, but I’m not sure why it doesn’t work. There are no errors in the output either.
local box = script.Parent
while tonumber(box.Text) > 6 do
box.Text = "6"
wait(.1)
end
The script is a localscript inside of the textbox by the way. Could anyone provide help? Thanks.
Instead of using a while loop, you need to listen to the text change event.
local box = script.Parent
box:GetPropertyChangedSignal("Text"):Connect(function()
if tonumber(box.Text) > 6 then
----the number is not okay
box.Text = ""
else
----the number is okay
end
end)