Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
uhTeddy 101
6 years ago

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

Log in to vote
0
Answered by 6 years ago
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
Ad
Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

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.

0
That is not useful for when I need a value returned. uhTeddy 101 — 6y
0
Yes it is. You can simply fire the remote from server to client, and fire again from client to server. Avigant 2374 — 6y

Answer this question