When using online multiplayer functions in godot 4, I keep on getting "Unexpected 'Identifier' in class body."

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By naferrara10

I am doing the a youtube tutorial called “Godot 4 - Online Multiplayer FPS From Scratch” by DevLogLogan. Link: https://www.youtube.com/watch?v=n8D3vEx7NAE. I am trying to create the multiplayer part of it, which requires a function called “multiplayer.get_unique_id().” Only problem is that I keep on getting the unexpected identifier error. I am not sure if it has anything to do with UPnP(Universal Plug and Play). If anyone has any information on the unexpected identifier error, please share. Here is the script of the node that has the error:

extends Node

@onready var main_menu = $CanvasLayer/MainMenu
@onready var address_entry = $CanvasLayer/MainMenu/MarginContainer/VBoxContainer/AddressEntry

const Player = preload("res://player.tscn")
const PORT = 9999
var enet_peer = ENetMultiplayerPeer.new()

func _unhandled_input(event):
	if Input.is_action_just_pressed("quit"):
func _on_host_button_pressed():
	multiplayer.multiplayer_peer = enet_peer


func _on_join_button_pressed():
	pass # Replace with function body.

func add_player(peer_id):
	var player = Player.instantiate()
	player.name = str(peer_id)

Edited to fix code formatting.

jgodfrey | 2023-03-18 18:08

:bust_in_silhouette: Reply From: jgodfrey

The immediate problem is with this line of code:


It’s not indented properly. Fixing the indention will eliminate the error you mention.

Thank you so much

naferrara10 | 2023-03-18 18:17