LAN game connection works when running on one computer but not when running on two different devices

Godot Version: 4.2.1

Hi there! I am having trouble with a game a I am working on. We are building a LAN connection system for users who are on the same network to be able to automatically start, and join a game together. This system seems to work great when running multiple instances on one computer, either in editor or as an exe. But as soon as I try to do it on two different computers we run into issues. Depending on which device is hosting sometimes the client will see the host and try to tun the add_player method, sometimes the client will just be unable to see the hosts broadcast at all and will never attempt to connect.

I am kinda at a loss here so would really appreciate some advice. I will include our main environment script which handles all the networking code at the moment. Thanks

extends Node3D

var peer =
@export var player_scene: PackedScene

var broadcast_timer: Timer
var server_info = {"server_ip": "","player_count": 0}
var broadcaster : PacketPeerUDP
var listner : PacketPeerUDP
@export var listen_port : int = 9998
@export var broadcast_port : int = 9999
@export var broadcast_address : String = ''
var listener_ready: bool = false

signal server_found

func _ready():
	if and Util.LAN:
	if Util.joining and Util.LAN:
	if and Util.offline:

func _process(_delta):
	if Input.is_action_just_pressed("esc"):
		Util.paused = not Util.paused
	if listener_ready:
		if listner.get_available_packet_count() > 0:
			var serverip = listner.get_packet_ip()
			var serverport = listner.get_packet_port()
			var bytes = listner.get_packet()
			var data = bytes.get_string_from_ascii()
			var roomInfo = JSON.parse_string(data)
			print("server Ip: " + serverip +" serverPort: "+ str(serverport) + " room info: " + str(roomInfo))
			if serverip != "" and roomInfo.player_count < 4:
				broadcast_address = serverip
				broadcast_port = serverport
			#print("listner found no packet")

func _find_ip():
	var addresses = IP.get_local_addresses()
	for item in addresses:
		if item.contains("10.") or item.contains("192.168"):
			var index = item.rfind(".")
			if index != -1:
				server_info.server_ip = item
				item = item.substr(0, index + 1)
				return item + "255"

func _start_lan():
	broadcast_address = _find_ip()
	print("Broadcasting on address: " + broadcast_address)
	var error = peer.create_server(broadcast_port)
	if error != OK:
		print("cannot host: " + str(error))
	multiplayer.multiplayer_peer = peer
	print("Waiting For Players!")

func _set_up_broadcast():
	server_info.player_count = 1
	broadcast_timer = $MultiplayerSpawner/BroadcastTimer
	broadcaster =
	broadcaster.set_dest_address(broadcast_address, listen_port)
	var ok = broadcaster.bind(broadcast_port)
	if ok == OK:
		print("Bound to Broadcast Port "  + str(broadcast_port) +  " Successful!")
		print("Failed to bind to broadcast port!")
func _add_player(peer_id = 1):
	print("adding player")
	var player = player_scene.instantiate() = str(peer_id)
	call_deferred("add_child", player)
	server_info.player_count += 1
	print("player added")
	return player
func _remove_player(peer_id):
	var player = get_node_or_null(str(peer_id))
	if player:
	server_info.player_count -= 1
func _join_lan():
	await server_found
	var join = peer.create_client(broadcast_address, broadcast_port)
	print("Join Error: " + str(join))
	multiplayer.multiplayer_peer = peer
	print('joined game')
	listener_ready = false

func _set_up_listener():
	listner =
	var ok = listner.bind(listen_port)
	if ok == OK:
		print("Bound to listen Port "  + str(listen_port) +  " Successful!")
		print("Bound To Listen Port: true")
		listener_ready = true
		print("Failed to bind to listen port!")
		print("Bound To Listen Port: false")

func _on_broadcast_timer_timeout():
	var data = JSON.stringify(server_info)
	var packet = data.to_ascii_buffer()

func _on_connection_timer_timeout():

func _return_to_menu():
	multiplayer.multiplayer_peer = null
	Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

Honestly not sure what happened, but it works now, no problem with no changes, so I guess problem solved? But I would like to try and know what was wrong for future reference.

PS: Your local address check is missing 172.16.xx.xx (on top of 10.xx.xx.xx and 192.168.xx.xx).