If statement is not working correctly

When I try to run the bottom code with the code being 1 and door being 1 it does not print correct. It does print Door! and the print of code is correct.

wait(0.5)
local Door1Code = math.random(1111,9999)
game.ServerStorage:WaitForChild("Door1Code").Value = Door1Code

game.ReplicatedStorage.TestCode.OnServerEvent:Connect(function(plr, door, code)
	print(plr)
	print(door)
	print(code)
	if door == 1 then
			print("Door!")
		if code == 1 then
				print("Correct!")
			return true
		end
	end
end)

are you sure that code is a number and not a string? try if tonumber(code) == 1 then

1 Like

That fixed the issue, thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.