Need help turning a textbox to numbers only

my bad if the title might seem a little confusing, but im trying to make a textbox that can support negative numbers, decimals and positive numbers, ive already implemented it so it only supports numbers negative symbols and decimals but my problem is that you can type the negative symbols more than twice same thing with a decimal
image
which leads into that
i dont know how to make it to limit certain characters so thats what I need help with
this is my current script

Parent.X:GetPropertyChangedSignal("Text"):Connect(function()
	Parent.X.Text = Parent.X.Text:gsub("[^%d%.%-]", '')
end)

Try using this as an example:

local lineFound = false

local Characters = TextBox:split("")

for i, v in ipairs(Characters) do
       if Characters[i] == "-" then
             if lineFound == false then
                   lineFound = true
             else
                   table.remove(Characters,i)
             end
       end
end

Then concat the table into a string and edit the text. Can’t think of anything else.