# Fortnite Game

**URL:** <https://forum.makecode.com/t/fortnite-game/7249>\
**Category:** Help\
**Created:** [April 8, 2021, 4:03am UTC](https://forum.makecode.com/t/fortnite-game/7249 "2021-04-08T04:03:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 4:03am UTC](https://forum.makecode.com/t/fortnite-game/7249/1 "2021-04-08T04:03:32Z")

</div>

I need help with this. Please help!!

---

<div class="post-metadata">

**Author:** ![girlwhocode](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/girlwhocode/32/3754_2.png) [@girlwhocode](https://forum.makecode.com/u/girlwhocode)\
**Post date:** [April 8, 2021, 2:06pm UTC](https://forum.makecode.com/t/fortnite-game/7249/2 "2021-04-08T14:06:10Z")

</div>

i can help but right now ima be too busy so i can help in some hours

---

<div class="post-metadata">

**Author:** ![Primal\_Nexus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/primal_nexus/32/3540_2.png) [@Primal\_Nexus](https://forum.makecode.com/u/Primal_Nexus)\
**Post date:** [April 8, 2021, 3:08pm UTC](https://forum.makecode.com/t/fortnite-game/7249/3 "2021-04-08T15:08:52Z")

</div>

I’d love to! What type of stuff is there going to be? (top-down? guns? heals/meds/shields?

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 3:09pm UTC](https://forum.makecode.com/t/fortnite-game/7249/4 "2021-04-08T15:09:08Z")

</div>

ok thanks

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 3:09pm UTC](https://forum.makecode.com/t/fortnite-game/7249/5 "2021-04-08T15:09:51Z")

</div>

> **[Fortnite!](https://arcade.makecode.com/96447-70183-64752-90758)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 4:23pm UTC](https://forum.makecode.com/t/fortnite-game/7249/6 "2021-04-08T16:23:59Z")

</div>

I am working on adding skins

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 4:28pm UTC](https://forum.makecode.com/t/fortnite-game/7249/7 "2021-04-08T16:28:52Z")

</div>

I need help with some on my code.

here it is:  
it says there is a problem in this:

controller.left.onEvent(ControllerButtonEvent.Pressed, function() {  
game.splash(“Locker”)  
let Locker: 1  
})  
forever(function() {

```
if (Locker == 1 ) {

}

```

})

---

<div class="post-metadata">

**Author:** ![girlwhocode](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/girlwhocode/32/3754_2.png) [@girlwhocode](https://forum.makecode.com/u/girlwhocode)\
**Post date:** [April 8, 2021, 5:02pm UTC](https://forum.makecode.com/t/fortnite-game/7249/8 "2021-04-08T17:02:28Z")

</div>

you cant move

---

<div class="post-metadata">

**Author:** ![xavvvvvv](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/xavvvvvv/32/15324_2.png) [@xavvvvvv](https://forum.makecode.com/u/xavvvvvv)\
**Post date:** [April 8, 2021, 5:03pm UTC](https://forum.makecode.com/t/fortnite-game/7249/9 "2021-04-08T17:03:03Z")

</div>

Lets go fortnite

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 5:29pm UTC](https://forum.makecode.com/t/fortnite-game/7249/10 "2021-04-08T17:29:17Z")

</div>

youre not supposed to move

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 5:32pm UTC](https://forum.makecode.com/t/fortnite-game/7249/11 "2021-04-08T17:32:48Z")

</div>

here’s the updated one:

> **[Fortnite (Now with menu music!)](https://arcade.makecode.com/65764-75114-68273-00656)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [April 8, 2021, 5:33pm UTC](https://forum.makecode.com/t/fortnite-game/7249/12 "2021-04-08T17:33:05Z")

</div>

First, you should always put your code between backticks, like this:  
```typescript  
// My code here  
```  
Becomes:

```typescript
// My code here

```

(The “typescript” after the backticks will make the code syntax highlight)

Next, you should always indent. I can’t tell if you are indenting because you didn’t put the code between backticks. So your code should look like this:

```typescript
controller.left.onEvent(ControllerButtonEvent.Pressed, function() {
    game.splash(“Locker”)
    let Locker: 1
})
forever(function() {
    if (Locker == 1 ) {
        
    }
})

```

There are two problems:

1. The way to define variables is like: `let <variable_name>: <variable_type> = <starting_value>`. So it should be `let Locker: number = 1`.
2. Since you defined `Locker` inside the `controller.left.onEvent` function there is a high chance of `Locker` not being defined in when it is referenced in the `forever` function. One way to solve this (albeit slightly frowned upon when you can avoid it but whatever) is to use global variables. So you have to move the definition out of the function and put it at the very beginning.

Try to figure it yourself! If you can’t figure it out, here is the solution:

```typescript
let Locker: number = 1
controller.left.onEvent(ControllerButtonEvent.Pressed, function() {
    game.splash(“Locker”)
})
forever(function() {
    if (Locker == 1 ) {
        
    }
})

```

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 5:52pm UTC](https://forum.makecode.com/t/fortnite-game/7249/13 "2021-04-08T17:52:32Z")

</div>

i used the solution but now my new code isn’t working either, saying there is a expression expected:

let Locker: number = 1  
controller.left.onEvent(ControllerButtonEvent.Pressed, function() {  
game.splash(“Locker”)  
})  
forever(function() {  
if (Locker == 1 ) {  
if (controller.A.isPressed() ()

)  
}})

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [April 8, 2021, 6:15pm UTC](https://forum.makecode.com/t/fortnite-game/7249/14 "2021-04-08T18:15:27Z")

</div>

It’s because you didn’t close the `if` statement properly - it should be something like this:

```typescript
if (statement) {
   // your code here
}

```

Solution:

```typescript
forever(function() {
    if (Locker == 1) {
        if (controller.A.isPressed()) {
            
        }
    }
})

```

Maybe it would help to do it in blocks and switch to TypeScript to see how it actually works???

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 6:58pm UTC](https://forum.makecode.com/t/fortnite-game/7249/15 "2021-04-08T18:58:31Z")

</div>

Thanks!! Thanks to you, I think i finished my game!!

> **[Fortnite (Now with menu music!)](https://arcade.makecode.com/19885-84074-79717-33717)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Danscotty](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@Danscotty](https://forum.makecode.com/u/Danscotty)\
**Post date:** [April 8, 2021, 10:13pm UTC](https://forum.makecode.com/t/fortnite-game/7249/16 "2021-04-08T22:13:30Z")

</div>

Wait what are we supposed to do?

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 8, 2021, 10:39pm UTC](https://forum.makecode.com/t/fortnite-game/7249/17 "2021-04-08T22:39:21Z")

</div>

Press A to loot. when you press B, if the last thing you got was a weapon, you ambush/raid enemies with it.

---

<div class="post-metadata">

**Author:** ![Danscotty](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@Danscotty](https://forum.makecode.com/u/Danscotty)\
**Post date:** [April 9, 2021, 12:50am UTC](https://forum.makecode.com/t/fortnite-game/7249/18 "2021-04-09T00:50:41Z")

</div>

but if you keep spamming a you keep getting more and more hearts

---

<div class="post-metadata">

**Author:** ![ImaAngryBear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/imaangrybear/32/3834_2.png) [@ImaAngryBear](https://forum.makecode.com/u/ImaAngryBear)\
**Post date:** [April 9, 2021, 3:17pm UTC](https://forum.makecode.com/t/fortnite-game/7249/19 "2021-04-09T15:17:13Z")

</div>

I’ts a chance thing. just see what you get!

---

<div class="post-metadata">

**Author:** ![Primal\_Nexus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/primal_nexus/32/3540_2.png) [@Primal\_Nexus](https://forum.makecode.com/u/Primal_Nexus)\
**Post date:** [April 9, 2021, 5:07pm UTC](https://forum.makecode.com/t/fortnite-game/7249/20 "2021-04-09T17:07:18Z")

</div>

Yeah, my luck is absolutely bad (it’s literally 75-25 and I’m worried 😟)

[Next page](https://forum.makecode.com/t/fortnite-game/7249.md?page=2)
