How To Make Negative And Positive Numbers Only Text Box?

I was making a textbox where only numbers could be written, but I noticed that negative numbers could not be written, so - symbol could not be used, can you help me?

My Code:

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	script.Parent.Text = script.Parent.Text:gsub('%D+', '');
end)

Maybe one of these would help

2 Likes
local Script = script
local TextBox = Script.Parent

local function OnTextChanged()
	TextBox.Text = string.gsub(TextBox.Text, "[^%d%-%.]", "")
end

TextBox:GetPropertyChangedSignal("Text"):Connect(OnTextChanged)
4 Likes