Why is this script duplicating the value every time instead of looking for one that exists?

I’m making a plugin and the current issue as stated in the title is that Instead of my function searching for that value with that specific name it’s actually duplicating it every time I run the function.

local function goto()
	local duration = tonumber(PageInsert.Text)
	if duration and duration <=amountofD.Value then
		number.Text = PageInsert.Text
		number.Text = "P"..number.Text
		for _, v in pairs(CHDIALOG:GetDescendants()) do
			if v.Name == number.Text then
				insertDialog.Text = v.Value
				--[[number.Visible = true
				Finish.Visible = true
				insertDialog.Visible = true
				CloneTemplate.Visible = true--]]
			else
				local ValueFor = Instance.new("StringValue")
				ValueFor.Name = number.Text
				ValueFor.Value = insertDialog.Text
				ValueFor.Parent = CHDIALOG
				--[[number.Visible = true
				Finish.Visible = true
				insertDialog.Visible = true
				CloneTemplate.Visible = true--]]
			end
		end
	end
end
gotopage.MouseButton1Click:Connect(goto)

Result after copying the output into startergui:
https://gyazo.com/54ba45478e929100d0fe3a64f90a371b

Tbh not really sure what this function does, but in the loop, every time the value does not equal the number text, it creates a new one. So even if there is a value that equals the number text, every other value will create a new one.

What you could be doing instead is searching through the whole table, and at the end, if none of them equal the number, then create a new one?

Alternatively, not sure if table.find() could be of use here.
https://developer.roblox.com/en-us/api-reference/lua-docs/table