How to add the value of an IntValue in a TextBox without dying?

Hi, as you can see in the title, I am trying to add an IntValue which is equal to the text of a Texbox, in a condition, when it reaches 5M of strength in figures in the leadersstats, when the condition of reaching 5M of force should be added instantly to the value of the IntValue called SpeedValue, and the change in the text of the TextBox should also occur since both values are equal or synchronized but it does not, it only changes when I reset the character, everything is doing in a local script which is the following:

local SetSpeedBox = script.Parent
local SpeedValue = script.Parent.SpeedValue
local SpeedNumber = tonumber(SetSpeedBox.Text)
local player = game.Players.LocalPlayer

if player.leaderstats.Strength.Value >= 0 then
	SpeedValue.Value = SpeedValue.Value + 1
	wait()
	SetSpeedBox.Text = SpeedValue.Value
end
if player.leaderstats.Strength.Value >= 5000000 then
	SpeedValue.Value = SpeedValue.Value + 1
	wait()
	SetSpeedBox.Text = SpeedValue.Value
end
if player.leaderstats.Strength.Value >= 10000000 then
	SpeedValue.Value = SpeedValue.Value + 1
	wait()
	SetSpeedBox.Text = SpeedValue.Value
end

SetSpeedBox.FocusLost:Connect(function(Pressed, Click)
	if  Click.UserInputType == Enum.UserInputType.MouseButton1 or Pressed then
		print("Off!")
		if SpeedValue.Value == 1 then
			SetSpeedBox.Text = SpeedValue.Value
			if SpeedValue.Value >= 1 then
				SetSpeedBox.Text = SpeedValue.Value
			end
		end
		if SpeedValue.Value == 2 then
			SetSpeedBox.Text = SpeedValue.Value
			if SpeedValue.Value >= 2 then
				SpeedValue.Value = SetSpeedBox.Text
			elseif SpeedNumber == "1" or "2" and Pressed then
				SpeedValue.Value = SetSpeedBox.Text
			end
		end
		if SpeedValue.Value == 3 then
			SetSpeedBox.Text = SpeedValue.Value
			if SpeedValue.Value >= 3 then
				SpeedValue.Value = SetSpeedBox.Text
			elseif SpeedValue == "1" or "2" or "3" and Pressed then
				SpeedValue.Value = SetSpeedBox.Text
			end
		end
	end
end)
SetSpeedBox:GetPropertyChangedSignal("Text"):Connect(function()
	SetSpeedBox.Text = SetSpeedBox.Text:gsub("%D+", "");
end)

I do not know if I am letting something happen or if there is something in the code, everything seems to work as I want but the value does not change the moment the condition is met, only when doing a reset and also there I try to do that if it tries to change a value greater than it should have, it is changed to the previous value but if it is less, then it is left with that change but it does not seem to work either.

Thanks for reading and I look forward to some help!

I don’t really understand what you’re trying to do. Could you simplify the problem a bit? Maybe break up some of those very long run-on sentences :slight_smile:

Ok, maybe i didn’t explain my problem correctly, sorry, im trying to make a system that you can set velocity or size with numeric values, but im trying in this case when i have 5M strength in my leaderstats, then the value that is in my textbox in text get +1