Why am I getting the error for my code?

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

Im using the script to display my model

var currentplayerOne = PlayerSelectionManager.playerOne.instance() 
	Globals.playerOne.set_name(str(get_tree().get_network_unique_id()))
	Globals.playerOne.set_network_master(get_tree().get_network_unique_id())
	Globals.playerOne.global_transform = playerOne.position = Vector2(1.391, 0.718, -1.482).global_transform
	Globals.playerOne.set_script(PlayerSelectionManager.playerScript)
	add_child(Globals.playerOne)

What causes this error?

  • Parse Error: Unexpected assign.

if you could take a screenshot showing the error code line it would be easier to know what the problem is.

Cire_arievilo1 | 2022-11-04 04:11

:bust_in_silhouette: Reply From: Wakatta
Globals.playerOne.global_transform = playerOne.position = Vector2(1.391, 0.718, -1.482).global_transform

This C/C++ style assign is not tolerated in GDScript.
Vector2’s have no such property as global_transform.

Globals.playerOne.global_transform = Vector3(1.391, 0.718, -1.482)
playerOne.position = Vector3(1.391, 0.718, -1.482)

or

Globals.playerOne.global_transform = Vector3(1.391, 0.718, -1.482)
playerOne.position = Globals.playerOne.global_transform

Also, Vector2(1.391, 0.718, -1.482) won’t work. Use Vector3(1.391, 0.718, -1.482), or eliminate a dimension, whichever is appropriate for the circumstances.

stormreaver | 2022-11-04 13:51

Wow didn’t even notice. Just copypasta.

Looks like the new property position on Spatial correction Node3D is already causing confusions.

One of the reasons why it’s important to always use functions to assign vars and not directly with globals everywhere

Wakatta | 2022-11-04 15:55