How should I be handling this?

Hello, so right now, Im trying to make a system where UI will be applied to a pannel in the workspace on the Players Client, but then now I’m wondering how I should be handling it.

Normally you can have a LocalScript to Handle it, where I would Apply the Values from a ModuleScript and that is that, but then it doesnt seem to be efficient having multiple Scripts for a Specific task, I was also thinking about the usage of one LocalScript, or just simply using the Server.

What should I be doing? and what would be more efficient and better optimized for the task?

2 Likes

I think the best approach would be to have only one LocalScript and a module script that do specific task as it child.

Something like this.

image

and you can use CollectionService to decide what task to run inside the UIHandler which i think will be the most efficient way to do it.

Or you can just have a table that define the task, if you wish to keep it at one LocalScript only.

Doesnt really help.

Also, CollectionService isnt nessecary as i dont need to define what a specific object is, or does. I’ll just be using a UI for a specifc task or location.

What caveats do you think could happen by using just Server to populate the SurfaceGui?

Because, its the method I mostly use, like a leaderboard and the data is always handled by server, then if the panel is populated by the server theres no need for client to handle anything. I dont know if its a good practice but, its simpler

You dont use the Server to Handle Details, Its usually the Client

I see, but what is “details”?
Example, if I have a leaderboard populated with the names and points of the top 3 players in the history of game, and server just get the ordered datastore and clone frames, place them in the surfaceGui in workspace.
What would be a better approach? Sending that data to client using remotes so the client populate that leaderboard?

I think that depends on the goal of your “panel in workspace”, how often it populates, from where is populating the data, how you are sending that data, etc. To find an efficient approach maybe.

User Interface which includes SurfaceGui, Visual Effects like slashing a sword, for firing a weapon so there is no delay and not a burden on the Server to Handle it, and Animations.

Also, Its not a leaderboard. Its more of stuff like a Shopz or an Update Log.

The choice of how to handle your UI in Roblox depends on the specific requirements of your project. Here are some factors to consider:

  1. Client vs. Server: If the UI is only displayed to the local player, and doesn’t need to be shared with other players or the server, then you can use a LocalScript. However, if the UI needs to be synchronized across players or needs to interact with server-side data, then you’ll need to use a server-side Script or a RemoteEvent.
  2. Modularization: Having multiple scripts isn’t necessarily inefficient if each script has a specific purpose and they can be easily managed. Using a module script to store common code that can be reused across scripts can also help keep your code organized.
  3. Performance: If you’re concerned about performance, keep in mind that certain operations (like accessing GUI elements) can be slow and should be minimized. You can use functions like FindFirstChild to cache references to GUI elements instead of accessing them repeatedly.
  4. Complexity: If your UI is relatively simple, you might be able to handle everything in one script. However, if your UI is more complex and has multiple components, it may be easier to manage if you split the functionality across multiple scripts.

In general, it’s a good idea to start with a modular approach and split your functionality across multiple scripts if necessary. If you’re unsure about the best approach, you can start with a LocalScript and refactor as needed.

Doesnt really help either as im already doing this, just asking if its efficient or not, and what would be more efficient.