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

How to run a remote event at the same time for everyone?

Asked by
tantec 305 Moderation Voter
4 years ago
Edited 4 years ago

So I'm trying to fire a remote event for all clients at the same time ( so every client runs it at the same time locally ). How would you do this regardless of lag, I understand you need to add a timeout in case someone is lagging too much.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Hello, tantec! It is easy. Just use the RemoteEvent:FireAllClients() function. Unlike FireClients(), it doesn't require a player instance. The FireAllClients() function should fire a RemoteEvent at the same time for everyone. Here's an example:

Server:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChildOfClass("Humanoid") then
        game:GetService("ReplicatedStorage").TouchGuiEvent:FireAllClient()
    end
end)

Client:

game:GetService("ReplicatedStorage").TouchGuiEvent.OnClientEvent:Connect(function()
    script.Parent.TextLabel.Text = "A humanoid has touched a part!"
end)

If this helped you please accept this answer.

0
No, I mean. I know how to do this, it's just that, how would you make it so everybody runs it at the same time. Like for example, there's going to be laggy people and firing to the client will take much longer than for someone with lower ping. Is there anyway to get around this? tantec 305 — 4y
Ad

Answer this question