Past threads include a link to the documentation claiming a limit of 20 times per second but the limit details have been removed from the documentation.
Is there a limit for RemoteEvents? I’m aware that they’re handled by the client so perhaps throttling won’t be an issue but it’ll cause the client to lag.
I’ve made an inventory system and I’m planning to update the inventory GUI every time a new item is added but the acquisition of individual items may result in hundreds of RemoteEvents firing. I’m currently planning to reinstate the GUI with backlogs of items but it’s not ideal. Is there a better way to manage this efficiently?
I cannot, with absolute certainty, comment on hard-limits for RemoteEvents. Generally speaking though, it’s a good idea to minimize the amount of RemoteEvents fired and size of data passed. You’re unlikely to encounter problems with PC users until a certain point, but it’s always helpful for mobile users to keep network usage minimal.
For your inventory GUI, it would be a relatively poor idea to send the entire inventory to the client each time a single item is added. Instead, cache the player’s inventory on the client. The server can then notify the client when an item is added or removed.
Here’s a (very simple) example of how you might implement this in code:
local itemAddedEvent: RemoteEvent
local itemRemovedEvent: RemoteEvent
local inventory = {}
-- It might make more sense to have separate functions for adding and
-- removing an item from your inventory gui rather than a single one.
local function renderGui() end
itemAddedEvent.OnClientEvent:Connect(function(id, item)
inventory[id] = item
renderGui()
end)
itemRemovedEvent.OnClientEvent:Connect(function(id)
inventory[id] = nil
renderGui()
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.