This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Im trying to make the selection script similar to sports games

var currentfighterOne = BoxerSelectionManager.fighterOne.instance() 
Globals.fighterOne.set_name(str(get_tree().get_network_unique_id()))
Globals.fighterOne.set_network_master(get_tree().get_network_unique_id())
Globals.fighterOne.position.global_transform = Vector3(1.391, 0.718, -1.482
if (BoxerSelectScript.challengerBoxer = playerOne)
    Globals.fighterOne.set_script(FighterSelectionManager.playerScript)
if (BoxerSelectScript.fighterOne = playerTwo)
    Globals.fighterOne.set_script(FighterSelectionManager.playerScript)
if (BoxerSelectScript.fighterOne = null)
    Globals.fighterOne.set_script(FighterSelectionManager.AIScript)
add_child(Globals.fighterOne)

I keep getting this error:
Unexpected assign

On this line:

if (BoxerSelectScript.challengerBoxer = playerOne)
Godot version 3.4
in Engine by (104 points)

1 Answer

+1 vote

When you Are try to see if a variable is equal to another
you need to use "=="

here is correct version

if (BoxerSelectScript.challengerBoxer == playerOne):

also one more thing, you will get another error if you do not put ":" after each IF statements

if you did exactly it would look like this (copy and paste)

var currentfighterOne = BoxerSelectionManager.fighterOne.instance() 
Globals.fighterOne.set_name(str(get_tree().get_network_unique_id()))
Globals.fighterOne.set_network_master(get_tree().get_network_unique_id())
Globals.fighterOne.position.global_transform = Vector3(1.391, 0.718, -1.482
if (BoxerSelectScript.challengerBoxer == playerOne):
    Globals.fighterOne.set_script(FighterSelectionManager.playerScript)
if (BoxerSelectScript.fighterOne == playerTwo):
    Globals.fighterOne.set_script(FighterSelectionManager.playerScript)
if (BoxerSelectScript.fighterOne == null):
    Globals.fighterOne.set_script(FighterSelectionManager.AIScript)
add_child(Globals.fighterOne)
by (30 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.