Problem with my script when comparing values

Hi I’m making a door code script with gui and in my previous post where Aanggoodluck solved the initial problem.

Now when I type in the correct code, it just says that the valued are not the same :

Code:

--local script

local KGUI = game.Players.LocalPlayer.PlayerGui.KeycodeGUI
local Chiffre = KGUI.Frame.Frame.CodeSee
local frame = script.Parent.Frame.Frame.Frame

game.ReplicatedStorage.EnableKGUI.OnClientEvent:Connect(function()
	KGUI.Enabled = true
	KGUI.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Back",1,false)
end)

KGUI.Frame.X.MouseButton1Click:Connect(function()
	KGUI.Enabled = false
end)

for i ,key in pairs(frame:GetChildren()) do
	if string.find(key.Name, "Key") then
		key.MouseButton1Click:Connect(function()
			Chiffre.Text ..= string.match(key.Name, "%d")
		end)
	elseif key.Name == "Back" then
		key.MouseButton1Click:Connect(function()
			Chiffre.Text = string.sub(Chiffre.Text,1,0)
		end)
	elseif key.Name == "Enter" then
		key.MouseButton1Click:Connect(function()
			script.Parent.Done.Value = true
			game.ReplicatedStorage.EnableKGUI:FireServer(script.Parent.Done.Value,Chiffre.Text)
		end)
	end
end
-- Server script

local remote = game.ReplicatedStorage.EnableKGUI

remote.OnServerEvent:Connect(function(player,complete,text)
	local CodeValue = script.Parent.Parent.Parent.Parent.Parent.PC.Screen.Code
	print(CodeValue.Value)
	local GUI = player.PlayerGui.KeycodeGUI
	GUI.Done.Value=complete
	GUI.Frame.Frame.CodeSee.Text =text
	if GUI.Done.Value == true then
		print("User has given a code")
		print(text)
		if text==CodeValue.Value then   -- This is where there's a problem
			print("CORRECT")
		else
			print("INCORRECT")
		end
	end
end)

script.Parent.Prompt.Triggered:Connect(function(player)
	game.ReplicatedStorage.EnableKGUI:FireClient(player)
end)


Remote location: image

Game file ( i’m not very good at explaining so maybe this helps ) :game.rbxl (67.5 KB)

image

5986 = the random generated code
1234= code given
INCORRECT = either the code is correct or not

image

5986 = the random generated code
5986= code given
INCORRECT = either the code is correct or not ( it should be correct )

1 Like

It could be that it’s incorrect because one is a string and the other is a number? Try this for that if statement?

if tonumber(text) == CodeValue.Value then

Is CodeValue an IntValue?

2 Likes

yes codevalue is an intvalue
characters limit ooof

1 Like

Then could it be what I had mentioned? Because the Text Property always returns a string, so it’s comparing your given code as a string to a number, mine converts the given text to a number and then compares, try it out

1 Like

yay it works thanks a lot I gtg quick bye

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like

Thanks a lot lol you solved me so much problems

1 Like