Goal: Implement the most efficient design in updating UI components for all players while not downgrading server security.
So I have been working on a project, and I am still new in the Roblox Lua universe. I come from a strong Java background and am now decent at modular programming in Lua, but I am concerned about performance as I am unsure how fast the server can process events for multiple clients.
My current method right now is a client sending information to the server that they are holding down a key and the position of that object is then updated for all other players through the client. I do this by updating the position on the server and then send every client the new position of that object. I know this sounds simple, but will this performance decrease when multiple clients are sending information where there are multiple objects moving on the screen? Will I need to use separate server scripts for each client to prevent lagging updates?
Thanks for your thoughts!
Will I need to use separate server scripts for each client to prevent lagging updates
No, it won’t improve the performance as Roblox uses green threading. Each time a client fired a Remote Function, it will just create a new thread.
this will decrease performance because of the amount of sending going on lold but idk the system you got going on as you didnt post details
(It’s 4:00am my time and I totally didn’t read that your goal was entirely related to UI elements so my initial (now deleted) post was concerning objects in Workspace. )
Ideally, you want the client to only send two events: when a user initially presses down a key, and when they let up the key. You can do this with BindAction. Please don’t use while loops for this kind of thing.
You can use FireServer pretty liberally - in-fact, this is the base of what getting a user’s average ping is. What matters most is the amount of data (in bytes) you’re sending when using FireServer. In this case, if all you’re sending is that the key is down/up, that’s not that much data - you could even consider it an A/B scenario, where no data is necessary to be sent, and your logic is all on the backend.
(i.e. if player isn’t in table of players with keys down, then their key isn’t down, otherwise if they are, then their key is down)
All of the networking and networking logic can be done in one server script. You’re probably fine sending UDim2s with FireAllClients at a regular interval, if that’s all it is. The issue becomes when you’re doing this for multiple GuiObjects which are moving based on different users’ inputs all at once and things start layering on top of one another.