This code works fully the first time then the second time I enter the code, it goes into the 'Error' function and says code isnt found. I entered the same code twice and it still didnt work the second time. Does anyone have any ideas to help?

Code=0
Dest=""
Via=""
Num=""
chnger=script.Parent.Changer.SurfaceGui.Frame

function Set()
	Code=script.Parent.Changer.SurfaceGui.Frame.Num.Text
	if script.Parent.DestCode.Value=="99" then
		Num="T1"
		Dest="Tester1"
		Via="T3"
		Cont()
	elseif Code=="0" then
		Num="T2"
		Dest="Tester2"
		Via="T4"
		Cont()
	else
		Error()
	end
end

function One()
	chnger.Num.Text=chnger.Num.Text..'1'
end
function Two()
	chnger.Num.Text=chnger.Num.Text..'2'
end
function Three()
	chnger.Num.Text=chnger.Num.Text..'3'
end
function Four()
	chnger.Num.Text=chnger.Num.Text..'4'
end
function Five()
	chnger.Num.Text=chnger.Num.Text..'5'
end
function Six()
	chnger.Num.Text=chnger.Num.Text..'6'
end
function Seven()
	chnger.Num.Text=chnger.Num.Text..'7'
end
function Eight()
	chnger.Num.Text=chnger.Num.Text..'8'
end
function Nine()
	chnger.Num.Text=chnger.Num.Text..'9'
end
function Zero()
	chnger.Num.Text=chnger.Num.Text..'0'
end

function Error()
	chnger.Frame.Dest.Text="CODE NOT VALID"
	chnger.Frame.Num.Text=" "
	print("Code: "..script.Parent.DestCode.Value.." is not valid")
	chnger.Num.Text=" "
	wait(2)
	chnger.Frame.Dest.Text=" "
end

function Cont()
	script.Parent.FrontDest.SurfaceGui.Frame.Dest.Text=Dest
	script.Parent.FrontDest.SurfaceGui.Frame.Num.Text=Num 
	script.Parent.FrontDest.SurfaceGui.Frame.Via.Text="Via "..Via
	script.Parent.SideDest.SurfaceGui.Num.Text=Num
	script.Parent.SideDest.SurfaceGui.Dest.Text=Dest
	script.Parent.RearNum.SurfaceGui.Dest.Text=Num	
	chnger.Frame.Dest.Text=Dest
	chnger.Frame.Num.Text=Num
	chnger.Num.Text=" "
	print("Complete")
end



chnger.Enter.MouseButton1Click:connect(Set)
chnger.One.MouseButton1Click:connect(One)
chnger.Two.MouseButton1Click:connect(Two)
chnger.Three.MouseButton1Click:connect(Three)
chnger.Four.MouseButton1Click:connect(Four)
chnger.Five.MouseButton1Click:connect(Five)
chnger.Six.MouseButton1Click:connect(Six)
chnger.Severn.MouseButton1Click:connect(Seven)
chnger.Eight.MouseButton1Click:connect(Eight)
chnger.Nine.MouseButton1Click:connect(Nine)
chnger.Zero.MouseButton1Click:connect(Zero)

5 comments

0

You set the Num.Text= " " (Space). In both the error function and the set function, that space carries out as part of it when you concatenate new numbers and none of your valid codes have a space at the beginning.

0

I removed the spaces and the same is happening.

0

Try printing out the right code and the code you entered side by side in the error message and see if you can spot a difference between the two

0

I clicked 99 both times then clicked Enter. Is there anything unsusual about the code as it works perfect the first time round. It is just the second time.

1

BUMP