'Else if' glitch

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

HollowwwMC

New Member
Jul 14, 2024
6
0
1
I'm trying to make code that when you spawn in for the first time, you get an item. But it keeps on saying that "'else' has to be placed just after an 'if' or 'else if' section"
Code:
on first join:
    set {_Number} to a random integer between 1 and 6
    if {_Number} is 1:
        give player {customitem::deepdarkbook}
        else if {_Number} is 2:
            give player {customitem::firebook}
            else if {_Number} is 3:
                give player {customitem::healthbook}
                else if {_Number} is 4:
                    give player {customitem::mobbook}
                    else if {_Number} is 5:
                        give player {customitem::spacebook}
                        else:
                            give player {customitem::speedbook}
can someone help me with this?
 
You need to indent properly


Code:
on join:
  set {_r} to a random integer between 1 and 3:
  if {_r} is 1:
    #do stuff
  else if {_r} is 2:
    #do stuff
  else if {_r} is 3:
    #do stuff
 
  • Like
Reactions: BaeFell
I'm trying to make code that when you spawn in for the first time, you get an item. But it keeps on saying that "'else' has to be placed just after an 'if' or 'else if' section"
Code:
on first join:
    set {_Number} to a random integer between 1 and 6
    if {_Number} is 1:
        give player {customitem::deepdarkbook}
        else if {_Number} is 2:
            give player {customitem::firebook}
            else if {_Number} is 3:
                give player {customitem::healthbook}
                else if {_Number} is 4:
                    give player {customitem::mobbook}
                    else if {_Number} is 5:
                        give player {customitem::spacebook}
                        else:
                            give player {customitem::speedbook}
can someone help me with this?
give player random element out of {customitems::*}