I'm trying to get my game completed, and what I need to finish it off is how I can update the GUI so all players have the same text. Basically what I'm trying to say is, my script (localscript) has a countdown that relies on the text label to display the countdown. It works, but the problem is the countdown is different for each player, causing different teleportation times and game starting times. Basically I want the countdown in sync with each player whether they join late or not. If that makes sense. I've done some research on how to do this, but none of this makes sense to me. All I need is some sort of example. Any help please? Thank you!
FireAllClients
is going to be your savior.
Essentially, have your game script and use the FireAllClients
function on a RemoteEvent in ReplicatedStorage.
Then, have a LocalScript on the client that recieves it using the OnClientEvent
event.
Script:
local re = game.ReplicatedStorage.UpdateUI --This is your RemoteEvent local timer = 60 --Game duration while true do for i = timer,0,-1 do re:FireAllClients(i); wait(1); end end
LocalScript:
local re = game.ReplicatedStorage.UpdateUI --This is your RemoteEvent local label = script.Parent --TextLabel or whatever to display on re.OnClientEvent:Connect(function(text) --'text' is what was passed label.Text = text; end)