Code door issue

The title is self-explanatory. Im using this code door system: How to make a door that has a password and a guide that says the numbers one by one

The code is this.



return function()
	local code = math.random(1111,9999)
	local p = script.Parent
	local button = p.Keypad
	local runservice = game:GetService("RunService")
	local display = script.Parent.Display
	local open = p.Door.Open
	local hints = p.Hints
	local current = ""
	
	for i,v in pairs(hints:GetChildren()) do
		local cstring = tostring(code)
		hints[tostring(i)].SurfaceGui.TextLabel.Text = string.sub(cstring,i,i)
		runservice.Stepped:Wait()
	end

	
	for i,v in pairs(button:GetChildren()) do
		v.ClickDetector.MouseClick:Connect(function()
			local input = v.SurfaceGui.TextLabel.Text
			print(input)
			
			for i = 1,10 do
				runservice.Stepped:Wait()
			end
			if string.lower(input) == "enter" then
				if current == tostring(code) then
					display.SurfaceGui.TextLabel.Text = "CORRECT"
					current = ""
					open:Play()
					for i=1,360 do
						runservice.Stepped:Wait()
					end
					display.SurfaceGui.TextLabel.Text = ""
				elseif current ~= tostring(code) then
					print(current)
					display.SurfaceGui.TextLabel.Text = "INCORRECT"
					display.SurfaceGui.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
					current = ""
					for i=1,60 do
						runservice.Stepped:Wait()
					end
					display.SurfaceGui.TextLabel.Text = ""
					display.SurfaceGui.TextLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
				elseif string.len(current) < 4 then
					current = current..input
					display.SurfaceGui.TextLabel.Text = current
				end
			end
		end)
	end
end

The issue is that. When I typed the code and press enter the CurrentInput does not change the string causing the code to think. I didn’t put the code because the CurrentInput is just blank.

(The script is a ModuleScript btw)

If you’re running this on the server-side, make sure to run it on the client-side because whatever happens on the client can’t replicate to the server. To determine when the client clicks the ClickDetector and has the input ready, you can use RemoteEvent to fire to the server for this procedure.

If you want more background on how to use Remote events and functions, refer to this Roblox article.