Studio has a script performance pop-up where I can select scripts which are causing lag. I saw a in-game (not studio) script (which is named “Script”) which is lagging very much. the question is, How to find that script bc I have a lot of scripts named “Script”.
A script is lagging only in-game and not in studio, how to find it? (because the name of the script is "script" and I have a ton of them)
It’s most likely a virus then. Either an admin panel for exploiters or some other access point to your server…
There was a great thread on the tutorial section about finding these… I’m sorry that I can’t look for it myself at the moment, but it should pop up pretty soon if you look for it!
rename ur scripts…why would u not rename ur scripts
I’m already doing that, but the problem is that I have like 500 scripts and it’s gonna take a while before I renamed them all.
Write another script to find all the scripts in your game and rename them using a for loop. Then whilst the game is running in studio use the workspace filter to display just scripts then select and copy them all. Now stop the game running, use the workspace filter to select all the scripts again, delete them all and then paste the renamed scripts into your game. If you don’t want to delete and paste them all, then you can at least see the name of the script causing lag while the game is running, you can then use the workspace filter to find the location in your work tree of the suspect script.
good idea, I’ll try. Thanks for your help.
No problem, I hope it works for you, this is a method I use myself to rename models with too many parts called ‘Part’ or anything with many object instances. Sometimes you code so fast and get into the moment that there is no time to stop the flow and be organised and rename stuff. But then afterwards you stare at the mess and say “Noooooooooooooooooo!!!”
does it have “While true do” in it?
Good call, if the suspect script does contain this, or in fact any script, it will probably be the underlying issue in any resource consuming process. You need strict logic and definitive cycle counting when you start an infinite loop. And my personal opinion is,
while true do loops should be condemned to the scrap heap for evermore. Nothing real or in existence uses a routine with a control system based on that condition.
while alive == true do works. But
while true do essentially translates to
while existence do. This is utter nonsense, this is akin to analysing timescales as vast as the lifespan of the universe and comparing them to the average life expectancy of a human being!
how are you having 500 scripts?
I have scripts with while true do but they aren’t even close to as slow as that script is. I also did add more time to the while true do loops so they cause less lag.
It’s in guis, tools, coins, things based on clock time, blocks that give speed, remote event triggers and much more other things.
So while alive == true do cause less lag than while true do when it’s almost the same code?!? Okay, good to know but it’s ridiculous because in my opinion that shouldn’t matter at all…
I can try that too. Thank you
I hope I could find the suspect script
while alive == true do was merely a metaphor for human existence, in that it makes more sense to check this than continue to do stuff whether the human is alive or not (i.e.
while true do, which will never be false, so = infinite). It was not a suggestion to use that in your code, merely the concept behind it, i.e. everything has a finite existence, so make sure your coding follows the same concept. Use finite looping or internal breaking mechanisms.
makes sense. Thanks for your help.