Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a way to fire a RemoteFunction to all players without using for i,v?

I have been looking to see if there is an InvokeAllClients or something of that sorts, and so far I have not seen anything. If there is something I could use please tell me.

2 answers

function invokeAllClients(remoteFunc, ...)
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
    remoteFunc:InvokeClient(player, ...) 
end

invokeAllClients(game:GetService("ReplicatedStorage").RemoteFunc) -- locate your remote function

You shouldn't invoke RemoteFunctions from server -> client. Clients can yield indefinitely, causing your server to wait for who knows how long.

I recommend using RemoteEvents for this.

2 comments

0

That is not useful for when I need a value returned.

0

Yes it is. You can simply fire the remote from server to client, and fire again from client to server.

This discussion is preserved as it was. New answers, comments, and votes are closed.