What’s wrong with my code?

I’m not sure what to do from here or how to fix please help

1 Like

Hi , Looks like you have a syntax error in your code. The error message indicates that there is a dangling ‘=’ assignment with no expressions or empty bracket block ‘{}’ on its right-hand side.

Here’s your code with a potential correction:

else:
    (Player:player):void=
    Logger.Print("=== GetRandom Function Activated ===")
    RandomNum:int = GetRandomInt(1, 3)
    Logger.Print("Picked Random Number. Number selected is {RandomNum}")
    set randomNumber = RandomNum
    if (randomNumber == 1):
        set winA = true
        TeleA.teleport(Player)
        Logger.Print("=== Winner A  ===")
    if (randomNumber == 2):
        set winB = true
        TeleB.Teleport(player)
        Logger.Print("=== Winner B ===")
    if (randomNumber == 3):
        set winC = true
        TeleC.Teleport(player)
        Logger.Print("=== Winner C ===")

Here are the changes I made:

  1. Replaced = with == in the if conditions to check for equality.
  2. Added colons : at the end of if conditions.
  3. Fixed the indentation to make the code structure clear.

Make sure to adapt the changes according to the specific syntax rules of Unreal Editor for Fortnite.
I hope I helped. He would be grateful if you left Subscriptions on my YouTube channel. Regards
YT:https://www.youtube.com/@grawik_ingraw

thank you it did fix that problem but now its saying that the first “else” is an “Expected expression, got “else” in indented block”. Not sure if you would need a picture to see but if you could help with that i would appreciate it and will for sure check out your youtube channel.

1 Like

Sure, I can help you with that. It seems there might be an issue with the indentation or the structure of your code. In the absence of a full context, I’ll provide a generic structure for a Python-like language, which is commonly used in Unreal Engine scripting. Adjust it according to the syntax rules of Unreal Editor for Fortnite:

if (condition):
    // Code block for the "if" condition
    // ...

else:
    // Code block for the "else" condition
    (Player:player):void=
    Logger.Print("=== GetRandom Function Activated ===")
    RandomNum:int = GetRandomInt(1, 3)
    Logger.Print("Picked Random Number. Number selected is {RandomNum}")
    set randomNumber = RandomNum
    if (randomNumber == 1):
        set winA = true
        TeleA.teleport(Player)
        Logger.Print("=== Winner A  ===")
    elif (randomNumber == 2):
        set winB = true
        TeleB.Teleport(player)
        Logger.Print("=== Winner B ===")
    elif (randomNumber == 3):
        set winC = true
        TeleC.Teleport(player)
        Logger.Print("=== Winner C ===")

Key points:

  1. The if and else conditions should be followed by a colon (:).
  2. Ensure consistent indentation within the else block.
  3. Replace if with elif for subsequent conditions within the else block.

Make sure to adapt this structure to the specific syntax rules of Unreal Editor for Fortnite. If the issue persists or if there are specific rules for Unreal Editor that differ from the generic structure I provided, please provide more details, and I’ll do my best to assist you.

Hi Fastgael,

You’ll have to disregard the other user - they appear to be using AI to answer your questions, and they are not correct.
Without being able to see the rest of the code, I’m not able to help to the best of my ability, but with what I can see I’ll try and give you as good information as I can.

For the first part, it looks like you won’t need

(Player:player):void=

As this is not correct syntax. I’m not sure what the original intention was, if you are able to clarify I might be able to help further. One thing I can tell you, however, is that it looks like the creation of a malformed extension function.

For the second part, the main issue at hand looks like you are trying to make a code block where it doesn’t need to be made.

The format you were looking for is the “spaced format.”
If you look past the line,

RandomNum:int = GetRandomInt(1, 3)

You should notice that there is an extra indentation where there doesn’t need to be one. You can fix this by highlighting all the code under this line and then pressing “Shift + Tab” at the same time. This will remove an indentation from the code, and should fix the proper syntax afterwards.

One thing that you should note is that unless Player is assigned somewhere at the top of your code, this will still not compile properly. You need to have a proper reference to the player you wish to teleport.
I recommend reading through the Verse language reference for some tips on how to use variables.

Verse is a very new language, and the documentation might not be as great for learning the basics of programming. If you’re just starting off, I’d recommend trying to make some example applications in a language such as Python so that you can get the basics down, as it will make using Verse much easier.