Problem with checking if it is the right code

  1. What do you want to achieve? When a player write the correct code something happen

  2. What is the issue? Basically if the code change (the code is into a value) then it marks the code wrong

LOOK

image
The code is changed two times (the intvalue on the script)

if i write the second one (so the right one) it gives me error
image

But if i write the first code
image

It give me correct and error in the same time

Basically i want that if code change do not get bugged

This is the script

script.code:GetPropertyChangedSignal("Value"):Connect(function()
	
local code = script.code.Value

--game.Workspace.ChildAdded:Connect(function(child)
--	if child.Name == "United Kingdom" then
		
		local UK = game.Workspace["United Kingdom"]
		local buttons = UK.PhoneBooth.Phone.Buttons.SurfaceGui
		local display = UK.PhoneBooth.Phone.Screen.SurfaceGui.Frame.TextLabel
		
		local currentinput = ""
		
		for i, button in pairs(buttons:GetChildren()) do
			
			button.MouseButton1Click:Connect(function()
				
				local buttoninput = button.Text
				
				if string.lower(buttoninput) == "enter" then
					
					if currentinput == tostring(code) then
						
						display.Text = "Correct!"
												
						--DO WHAT DO YOU WANT HERE
						
					
					
				elseif currentinput ~= tostring(code) then
					
					display.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
				display.Text = "⚠️Unable to find this phone number⚠️"
				currentinput = ""
					wait(1)
				display.Parent.BackgroundColor3 = Color3.fromRGB(43, 43, 43)
				display.Text = ""
				

			end
			
		elseif button.Text == "COR" then

			local stringa = display.Text 

			local astr = stringa:gsub(".?$","")

			display.Text = astr
			currentinput = astr
			
				elseif string.lower(buttoninput) == "clear" then
					
					currentinput = ""
					display.Text = ""
				else
					currentinput = currentinput..buttoninput
					display.Text = currentinput
					
					end
				
			end)

		end
		
--	end
	
end)

All answers are welcome :DD