Script lags only in one specific scene

So I have this script to measure the distance between two objects, use the shortest, and enable and disable entities from that number


This script works perfectly fine in every scene except one. In this one specific scene the CPU usage jumps from 4 when not activated to 20-30 when activated. I even disabled every single entity in the scene except for the player, camera, and the entities related to the script and it still lags the game. Is there some specific scene setting causing this to happen, or some objects in the game causing this to lag when used? Make sure to give the scene a couple seconds to load all assets. The script is activated by pressing R
Junk dont steal | Launch (playcanvas.com)

Hi @ALUCARD!

I have no problems in the scene I start with, when I click the link.

Try to do as less as possible in the update function of your scripts.