# Background saying "not a function" when creating a game in GameLab

**URL:** <https://forum.code.org/t/background-saying-not-a-function-when-creating-a-game-in-gamelab/36266>\
**Category:** Coding and Debugging Help\
**Created:** [May 2, 2022, 7:54pm UTC](https://forum.code.org/t/background-saying-not-a-function-when-creating-a-game-in-gamelab/36266 "2022-05-02T19:54:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlowther.om](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@rlowther.om](https://forum.code.org/u/rlowther.om)\
**Post date:** [May 2, 2022, 7:54pm UTC](https://forum.code.org/t/background-saying-not-a-function-when-creating-a-game-in-gamelab/36266/1 "2022-05-02T19:54:00Z")

</div>

([Game Lab - Code.org](https://studio.code.org/projects/gamelab/s8RC_fRBnVgPBYb2gTSDTiWbfFTawK9h-OSq-qNt3ZY))  
During the process of coding their games, they started getting an error message, “Background is not a function”. However, it does not happen to all students, even when using the same code. This causes their games not to run.  
I have tried changing up the code for the background, refreshing the page, deleting just the background block and readding it, and rewriting the whole program. Eventually it leads to the same issue for only some students.

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [May 3, 2022, 1:38pm UTC](https://forum.code.org/t/background-saying-not-a-function-when-creating-a-game-in-gamelab/36266/2 "2022-05-03T13:38:46Z")

</div>

@rlowther.om,

Are there certain conditions that make it happen? I played this game several times and didn’t get the the error message.

Mike

---

<div class="post-metadata">

**Author:** ![rlowther.om](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@rlowther.om](https://forum.code.org/u/rlowther.om)\
**Post date:** [May 3, 2022, 4:23pm UTC](https://forum.code.org/t/background-saying-not-a-function-when-creating-a-game-in-gamelab/36266/3 "2022-05-03T16:23:25Z")

</div>

She is getting the message on her end. It is happening on the Conditional for the game over (If score \<= 0, then display different background, etc).

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [May 3, 2022, 6:47pm UTC](https://forum.code.org/t/background-saying-not-a-function-when-creating-a-game-in-gamelab/36266/5 "2022-05-03T18:47:35Z")

</div>

@rlowther.om,

Actually, I think I found your problem. On line 10, she has renamed “background” to be a sprite. The word background is a reserved word that is already used by javascript to refer to the background block. On line 10, by renaming background to be a sprite, it causes a conflict that is most likely why the error is occurring.

Have her use a different name like bg or bckgrnd or something like that and it should solve the issue.

Mike

---

<div class="post-metadata">

**Author:** ![rlowther.om](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@rlowther.om](https://forum.code.org/u/rlowther.om)\
**Post date:** [May 3, 2022, 8:04pm UTC](https://forum.code.org/t/background-saying-not-a-function-when-creating-a-game-in-gamelab/36266/6 "2022-05-03T20:04:06Z")

</div>

Thank you! I will try that.
