# Scripts not working right

**URL:** <https://forum.playcanvas.com/t/scripts-not-working-right/38730>\
**Category:** Help & Support\
**Tags:** editor, scripting\
**Created:** [January 9, 2025, 8:37pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730 "2025-01-09T20:37:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 9, 2025, 8:37pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/1 "2025-01-09T20:37:19Z")

</div>

I’m having a problems with my game’s scripts working properly !  
For example I’ll try to load up my game and the files won’t work the proper way they were coded to be , and everywhere in the files can indeed work because I’ve been working on my game since last summer and up until January this year it’s started to act weird when I load my game up

Editor link - [https://playcanvas.com/editor/scene/2049206](https://playcanvas.com/editor/scene/2049206)

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 2:13am UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/2 "2025-01-10T02:13:39Z")

</div>

Hi @Kelvin_Riley2!

Based on the error it seems `loginBtn` doesn’t exist.

![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/e/3/e34ee1ead539464d634ff8d9b47c07c3c4cf7dfa.png)

You also need to (re)import the basis module.

You can do this in the project settings.

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/d/7/d784e082f206bad895b96fa9d9441f8e33387767.png)

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 5:03am UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/3 "2025-01-10T05:03:39Z")

</div>

I believe the `logingBtn` may be causing the error behind my scripts not working, And for the basis I already have one imported. Do I re-import another ?

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 5:12am UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/4 "2025-01-10T05:12:28Z")

</div>

@Albertos can you test out my game again to see my error i’m having trouble with ?  
the opening game scene is - [https://playcanvas.com/editor/scene/2049206](https://playcanvas.com/editor/scene/2049206)

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 12:59pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/5 "2025-01-10T12:59:48Z")

</div>

The Play Now button doesn’t work.

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/6/8/68e9b7c0aedf6f13def0b48293cf33e84899259b.png)

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 2:41pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/6 "2025-01-10T14:41:58Z")

</div>

@Albertos do you know how I can fix it then ? Strange thing is when I load up my other scene the game doesn’t work and it’s strange because all my script in the game leading up to now were functional. Can anyone help me figure this out ?

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 2:49pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/7 "2025-01-10T14:49:01Z")

</div>

Your project is very complex with a lot of scripts.

I don’t think the error has something to do with the button, so first I suggest to check the setup of the button to be sure everything is correct.

Can you share the scene that should be start when pressing the button?

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 3:09pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/8 "2025-01-10T15:09:33Z")

</div>

Code editor - ([PlayCanvas | HTML5 Game Engine](https://playcanvas.com/editor/code/1238409?tabs=201931188,204214912,189628896,189628970&focused=189628896))

Editor for “Next Scene” when you use the button - ([PlayCanvas | HTML5 Game Engine](https://playcanvas.com/editor/scene/2040303))

 ![Screenshot 2025-01-10 10.07.14 AM](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/7/d/7d6b9c3b5fc30eb91e1b9ff85b8ceb5ec990c0dc.png)  
 ![Screenshot 2025-01-10 10.05.51 AM](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/e/3/e378a486dd3cca29085a1f897f6077fb6c2cbed6.png)  
 ![Screenshot 2025-01-10 10.05.22 AM](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/0/3/0314a902eb9391337d825d26471781a6f637ae60.png)

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 3:13pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/9 "2025-01-10T15:13:47Z")

</div>

When I loaded that scene ([PlayCanvas | HTML5 Game Engine](https://playcanvas.com/editor/scene/2040303))  
and this one ([https://playcanvas.com/editor/scene/2049206](https://playcanvas.com/editor/scene/2049206))

the weird thing was that my game didn’t even load the texture, before I made this forum I had my basis in the game but even with it the texture in the game wouldn’t load in like that. I’m just really confused, I was wondering if it’s something with the draco, basis or ammo files

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 3:18pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/10 "2025-01-10T15:18:51Z")

</div>

You really need to find a way to see the errors in the console of your browser. (On a Windows device you can use the `F12` key to open the console).

You are also over your disk allowance limit, so maybe that can give some problems when you keep adding things.

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 3:23pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/11 "2025-01-10T15:23:18Z")

</div>

I did but for my console i’d get that same error you took a screenshot of yesterday, but I don’t know where to go from that though. I just need help because it’s been going on since Christmas now and I tried everything I could by reading other forums, asking ai and even trying to find YouTube videos other my similar situations

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 3:30pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/12 "2025-01-10T15:30:04Z")

</div>

Normally you click on the error to reach the line of code with the problem. From there you need to figure out why the line of code is giving the error.

For now I first suggest to clean up your project a bit. Maybe you can remove some large assets you don’t use or something?

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 3:32pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/13 "2025-01-10T15:32:45Z")

</div>

Ok, I will and after a few days i’ll update you on this problem. Thank you

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 3:44pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/14 "2025-01-10T15:44:12Z")

</div>

The loading type of all your script are set to ‘Before Engine’ for some reason, while it should be of type ‘Asset’.

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/1/5/15dc60b3a973c4c670391ca740a127b0e7590eb7.png)

Any reason you changed the loading type of your scripts?

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 3:48pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/15 "2025-01-10T15:48:33Z")

</div>

Yes because if you look into the loading screen script - ([PlayCanvas | HTML5 Game Engine](https://playcanvas.com/editor/code/1238409?tabs=201931188,204214912,189628896,189628798&focused=204214912))

I basically had it coded a way where the game can load up the “`eninge's assets`” in a faster way “In-game”, basically all the assets can be loaded up in the loading screen and wont cause any Laggy effects because every single Asset (Render assets, audio & more) can get loaded up all at once .

 ![Screenshot 2025-01-10 10.48.18 AM](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/0/7/0717eb5b8e18e1e7a75f3f858c6f8f95a9422afa.png)

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 4:16pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/16 "2025-01-10T16:16:47Z")

</div>

It seems there is a problem with that logic, because you can see on the console that your script are not loaded correctly.

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 10, 2025, 4:21pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/17 "2025-01-10T16:21:21Z")

</div>

Im going to replace the loading screen with a default loading screen then. Can you try to load my game up by the ( [https://playcanvas.com/editor/scene/2049206](https://playcanvas.com/editor/scene/2049206) ) scene ? Im currently on my laptop so I can’t test it out at the moment

---

<div class="post-metadata">

**Author:** ![Albertos](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/albertos/32/19749_2.png) [@Albertos](https://forum.playcanvas.com/u/Albertos)\
**Post date:** [January 10, 2025, 11:15pm UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/18 "2025-01-10T23:15:15Z")

</div>

It’s not only the loading screen. You need to change the loading type of your scripts.

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/3/1/315a2d355758d2fabf9a6a3bdfbcdca677a8c2dc.png)

I hope you don’t have 464 scripts in your project. 🙈

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 11, 2025, 3:11am UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/19 "2025-01-11T03:11:30Z")

</div>

I do 😅 Sadly I had to change it because of the “Loading screen Script” but what should I change the type to? should I do after engine, asset or before engine?

---

<div class="post-metadata">

**Author:** ![Kelvin\_Riley2](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/kelvin_riley2/32/24316_2.png) [@Kelvin\_Riley2](https://forum.playcanvas.com/u/Kelvin_Riley2)\
**Post date:** [January 11, 2025, 3:19am UTC](https://forum.playcanvas.com/t/scripts-not-working-right/38730/20 "2025-01-11T03:19:19Z")

</div>

I changed it all to `assets`, can you test it out for me?

[Next page](https://forum.playcanvas.com/t/scripts-not-working-right/38730.md?page=2)
