Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to use FireAllClients to update a GUI countdown across the server?

Basically, I have a GUI that displays a countdown, kills all players, teleports them to a random location, and rinse and repeat. What I'm stuck on is how to update the GUI from the server script service either using game.StarterGui.Game.Countdown.Text = "Test" or somehow using Remote Events/Fire All Clients. Here is my countdown script:

times = gameData.gameTime.Value
gtimenum = times
spawn(function() 
    while gameData.data.gameEnded.Value == false do
        if times <= 0 then
            times = gtimenum 
        else
            main.time_left.Text = ""..times
            wait(1)
            times = times - 1
        end
    end
end)

Any help appreciated.

1 answer

✓ Accepted answer

You can do this. Add a RemoteEvent to the ReplicatedStorage. ServerScript:

local remote = game:GetService('ReplicatedStorage').RemoteEvent
RemoteEvent:FireAllClients() --You can pass any arguments here to pass any from the server to the client.

LocalScript:

local remote = game:GetService('ReplicatedStorage').RemoteEvent
RemoveEvent.OnClientEvent:connect(function() --Put any argument names here.
	--insert your code here
end)

Also, to make custom functions, you need to do function spawn(), not what you did earlier.

4 comments

0

So I put the first thing of code into the Server Script Service, and put the local script where?

0

And what about my game script?

0

"custom functions" isn't a thing - he wrapped his function with 'spawn' earlier because of his loop, which may or may not be necessary depending on the rest of his code.

0

Put the local script in the PlayerGui.

This discussion is preserved as it was. New answers, comments, and votes are closed.