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

Can RemoteFunction fire to all clients?

Asked by
Seyfert 90
6 years ago

I am trying to avoid using RemoteEvents because they seem to have the problem of not going through if there is lag on the server, I have better luck with things going through with RemoteFunctions but is there a way to make a RemoteFunction fire to all players similar to how a RemoteEvent can?

0
Make a for i,v loop and just make the RemoteFunction Invoke every player? UltraUnitMode 419 — 6y

3 answers

Log in to vote
2
Answered by
XAXA 1569 Moderation Voter
6 years ago
Edited 6 years ago

It will not make sense to have RemoteFunction have some sort of InvokeAllClients() function. Since RemoteFunctions have to return something, how would the script store and process the result from multiple clients?

You're better off invoking it for each client manually. To prevent one invoke from blocking another, you can wrap each call in a spawn():

-- In a server script
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
    spawn(
        function()
            local returnVal = RemoteFunction():InvokeClient(player, arguments)
            -- process returnVal here
        end
    )
end
Ad
Log in to vote
1
Answered by
iSvenDerp 233 Moderation Voter
6 years ago
Edited 6 years ago

Hi! As Far as I know yes, RemoteFunctions can fire to all Clients...RemoteFunctions and RemoteEvents are both very Similiar, but the main and biggest difference is that in Remote Functions not only can the Server "Fire" to the Client, the Client can also "call back" and give a message back in the same Remote Function...But, Despite what you said about the lag...it is recommended that you use RemoteEvents over RemoteFunction, unless you need the Client or the Server to call back in the same Function.. More information over Remote Funtions here- http://wiki.roblox.com/index.php?title=API:Class/RemoteFunction Remote Functions also use the onClientInvoke instead of the onClientEvent like the RemoteEvent.. Hope this helped! Let me Know if it did! The Wiki has a lot more helpful information about this, check there!

Log in to vote
-2
Answered by 6 years ago

im not rlly sure what that is, so i cant help, but try putting a script in starterplayer, wich goes in the player that is in workspace

0
I told you about this before. ScriptGuider 5640 — 6y

Answer this question