It’s weird how it doesn’t have this, seeing how useful RemoteEvent:FireAllClients() is. The only work arounds I can think of are loop through every player and use :InvokeClient(), or just use another RemoteEvent. Do you guys have any other work arounds?
Why are you Invoking all the clients???
This is not a good practice. Use remote events instead and don’t yield for returns.
It doesn’t. I believe remote events have a similar function though.
RemoteFunctions are meant to return something, so a function like “InvokeAllClients” would need to return a set values for every player, and since there’s client->server communication going on there may not be a guarantee that every player will return something at the right time, or at all, which would complicate things.
Iterating through all the players would probably be the most practical workaround, but I don’t think Roblox anticipated any use-cases for this kind of function, so they didn’t add one.
It’s for a counter. I need to be able to request the number for the gui, when it’s created. And receive an event when that number updates.
There’s probably a better way to do what you’re trying to do, like having each client ping the server regularly with their info, rather than the server requesting that information from the players.
Using :InvokeClient()
is sorta discouraged anyway, since the client code could error or the player could exit the game mid-call and leave the server hanging.
The server doesn’t request anything from the client. The server only returns the counter for the gui when it is created. And whenever the counter updates, the server sends the new number to the client.
You shouldn’t be needing to use a RemoteFunction anyway, then.
If all you’re doing is updating players’ GUIs from the server, a RemoteEvent would suffice.
If you want to query data from the server use (Not recommend in most cases)
local Data = REMOTEFUNCTION:InvokeServer()
If you want to send data use
RemoteEvent:FireServer()/RemoteEvent:FireAllClients()/RemoteEvent:FireClient()
You see, I’m trying to use the RemoteFunction as a RemoteFunction, and as a RemoteEvent. When I’m using :InvokeAllClients() I’m not wanting anything to be returned. I just want to update the counter on the gui.
I see the confusion here, use RemoteEvents!
Use this on the client
Remote.OnClientEvent:Connect(function(Data)
-- Update the data
end
On the server
Remote:FireAllClients(Data)
This is what you are looking for! I swear
Oh yeah I’m using a RemoteEvent as a workaround. But I just find it annoying that you can’t just use :InvokeAllClients().
Such a function won’t work. What if different clients return different values?
And remote functions are meant to be used for returning data back to the other side. Just use a remote event. It isn’t annoying that an :InvokeAllClients
doesn’t exist.