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

Is it possible to fire 2 clients the same time?

Asked by 5 years ago
Edited 5 years ago

Hi, i want to fire a clientevent on 2 players the same time. When i just make

remote:FireClient(player1)

remote:FireClient(player2)

it first fires the event for player1 which takes some seconds then it fires player2. Is there a way to fire them at the same time?

3 answers

Log in to vote
0
Answered by 5 years ago

If for some reason it is waiting before firing the other client you could use a coroutine structure like this:

coroutine.resume(coroutine.create(function()    
    remote:FireClient(player1)
end))
remote:FireClient(player2)

This will run the code in it's own separate coroutine aside from the code beneath it.

0
They don't wait, also you should be using the built-in spawn function instead of the coroutine library. Sir_Melio 221 — 5y
0
thanks that works Jabba171 16 — 5y
0
@yankana I know that, I'm just saying "If for some reason it is waiting" here is a possible solution. climethestair 1663 — 5y
Ad
Log in to vote
0
Answered by
Delude_d 112
5 years ago
--Use "Spawn(function()"
-- Example
spawn(function()
plr:FireClient()
end)
-- rest is fine after you do it for first fire
Log in to vote
0
Answered by
Sir_Melio 221 Moderation Voter
5 years ago
Edited 5 years ago

FireClient should not take any seconds at all. It isn't a yield function which means it doesn't wait for anything. Doing what you posted should fire to both clients almost simultaneously, with a negligible difference which shouldn't matter due to other much bigger factors such as traffic delays.

0
I have a tween in the client event that takes some seconds. Thats what i meant. Jabba171 16 — 5y
0
Still, the OnClientEvent should be fired for both players at the same time, unless you consider traffic delays which you can't really do anything about. Sir_Melio 221 — 5y

Answer this question