In my game, the inventory needs to send requests to the server to perform certain actions, but the way that it’s done is through multiple scripts, and I feel as though it’s unoptimized
Example:
Client calls action
local HeldItem = TheValleyFunctions.GetHeldItem(Player)
TheValleyFunctions Module calls the remote function
function TheValleyFunctions.GetHeldItem(Player)
return RS.Inventory.GetHeldItem:InvokeServer(Player)
end
Server script listens for remote function
IF.GetHeldItem.OnServerInvoke = function(Player)
return InventoryFunctions:GetHeldItem(Player)
end
InventoryFunctions module gets the player’s inventory dictionary and applies function to said dictionary
function InventoryModule:GetHeldItem(Player)
local PlayerInventory = InventoryTables[Player.UserId]
return PlayerInventory:GetHeldItem()
end
Desired code finally runs
function Inventory:GetHeldItem()
return self.HeldItem
end
This causes noticeable delays in the UI actions