I want to know if “FireAllClient” will be an issue if I have 20 - 30 players are using the GUI?,
currently I am passing in a table that contain string value of current active lobby to the client for them to recreate that room for them self.
I am considering only updating the the player only when they are on that page only,
which is better?
Is there a better approach to this then what I am planning on doing here? And please let me get some concepts of what you guys think can below. Thanks!
--ServerScript
local DungeonRemoteEvent = game:GetService("ReplicatedStorage").Remotes.Events.UI.DungeonRemoteEvent
local DungeonRemoteFunction = game:GetService("ReplicatedStorage").Remotes.Functions.UI.DungeonRemoteFunction
local Lobby = {}
--[[lobby proxy is use to update the user lobby gui if anything changes on the server side we want to update the all the client]]
local lobbyProxy = {}
local metaLobbyProxy = {
__index = function(i, v)
print("Accessing orginal table element " .. tostring(v))
return Lobby[v]
end,
__newindex = function(lobbyProxy, i, v)
--print("Updating orginal element " .. tostring(i) .. " to " .. tostring(v))
Lobby[i] = v
UpdatePlayerLobbyGui()
end
}
setmetatable(lobbyProxy, metaLobbyProxy)
function UpdatePlayerLobbyGui()
DungeonRemoteEvent:FireAllClients()--Lobby)
end
I don’t know any proven efficient ways of updating clients GUI because there are a lot of scenarios that require different approaches, but this should reduce the amount of fired events overall.
On Client
You can check whether any player triggered the GUI (or page) by a LocalScript and fire the server.
On Server
You can then get the name of that specific player who fired the server, And update his GUI (or page) by getting his PlayerGui.
game.Players:FindFirstChild(Player Name from event).PlayerGui
Sweet sounds good, I got a ideal from reading what you shared, so I am now going to send the player over to the server side and put the player into a table and on the client side I am gonna have a bool value and if the player is on that page then page will update amount/time and if the player exit of that page the bool value will turn false and it will send the player back to the server and the server then will remove the client and not update his GUI anymore. Thanks
yes, ill let the client handle that, as it is not important to me if the GUI is update for the server or not. ill just let them request the update instead of me feeding them data every so seconds.
function DungeonGui:UpdateLobby(buttonName)
coroutine.resume(coroutine.create(function()
while self.BrowsingLobby do
local lobbyListScrollingFrame = self.LobbyListScrollingFrame
local currentLobbys = DungeonRemoteFunction:InvokeServer(buttonName)
local joinButton = self.JoinButton
local updatedFrame = self:AdjustButtonSize(lobbyListScrollingFrame, currentLobbys, joinButton)
self:UpdatePlayerButton(updatedFrame, currentLobbys)
wait(1)
end
end))