Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a cost to making tons of separate local scripts and scripts for things like Gui objects?

Asked by 6 years ago

This is something that I've been wondering for a long time.

Say for instance, I have a button that when you click it, it connects or teleports you to another place. I do all the code in a single local script that takes care of that button only.

Then for another button, I do the same.

This will eventually build up, is there a cost to do this at all?

2
There will be some overhead in setting up a script enviroment. As long as you can maintain the code then there should be no real issues. That being said making one script per button is just supid. User#5423 17 — 6y

2 answers

Log in to vote
0
Answered by
Sir_Melio 221 Moderation Voter
6 years ago
Edited 6 years ago

Well, having a lot of localscripts and they all are active, might unnecessarily be taking up performance. It is recommended that you handle things that work similarly in a single script rather than a script for each similar/semi-similar thing.

Since it seems like all the buttons function the same in your case, except probably to where the player is being teleported, you should have, for example, either an IntValue in each button, or a key for each button, in a table in the script with the value being the Id of the instance that you want the player to be teleported to. In that case, you can have a single script function with the exact same code for each button, by making it look for the Id that button has (wants to teleport the player to) in either the IntValue as a child of that button, or by a key used in a table to retrive that button's Id. The keys could be the names of the buttons, since that won't matter in the gameplay.

Ad
Log in to vote
0
Answered by 6 years ago

:Yeah, having a ton of scripts running consecutively could take up a fair amount of memory. If you'd like to run all of them in one script you could try using remote functions that are all handled by a single script, learn more about them here: http://http://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

:Having the local scripts call on the functions should not take up nearly as much memory and could help your performance if you need it enough.

Answer this question