Remote Event is not Firing!

Wait, I’m confused, do you have to keep firing the remote event like per second because players might join?

Depends on how you do it, if you make it that you fire the remote event once, and then the local script uses a for loop and changes the text, then people who join will miss it. But if you fire the remote event in a for loop, people who just joined will still get signals to change their text every second.

Sorry for the late reply

so like after the text changes from like 3 to 2 for example, you have to fire and receive 2 remote events? (Sorry if i ask a lot of questions, I’m new to this kind of topic.)

Nono, you should only use one remote event.
You should fire the remote event 30 times in a for loop, instead of just firing it once and having the local script change the text 30 times. Like the way you were doing it in the beginning.

like this?

      ''' 
       for i = 30,1,-1 do
              game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
              script.Parent.Text = "Game Starting in"..i
       end
              '''

Can anyone tell me if this will actually work?

Look, using remote events is a hassle, and I strongly recommend that you use a NumberValue to do this.

eg.

You have a NumberValue in game.ReplicatedStorage named TimeUntilNextRound.

The server updates the NumberValue, and the Player reads from the NumberValue. like so:

-- Server
local numberValue = game.ReplicatedStorage:WaitForChild("TimeUntilNextRound")

for i = 30,1,-1 do
       numberValue.Value = i
end

-- Player/Client

local numberValue = game.ReplicatedStorage:WaitForChild("TimeUntilNextRound")

numberValue:GetPropertyChangedSignal("Value"):Connect(function() -- when the server updates the countdown time
        print(numberValue.Value) -- there's your countdown time
end)
1 Like

Yeah but I don’t think new players will see the same text as the same time the oldest players will see
(or will it?)

They do. The SERVER updates it, not the client, so don’t worry. It will be the exact same time for al the players.

Even players that just join? and how about if i change the text ex: “Hello!” to “Bye!”

YES. It will work for those players as well.

Weird it doesn’t print anything, I added a number value called TimeUntilNextRound in ReplicatedStorage and tried your scripts

Do you have a clue why it is not printing?

Sorry, I forgot to add a wait(1) in the for loop on the server script. Add that, and it should work.

How would I do it with text on text label? (Sorry I ask for a lot of help and questions because I am not very experienced at scripting, I wish to get better)

Oh sorry, i didn’t see your message. Simply type these lines of code in the client script.

local textLabel = script.Parent -- the text label
local numberValue = game.ReplicatedStorage:WaitForChild("TimeUntilNextRound")

numberValue:GetPropertyChangedSignal("Value"):Connect(function() -- when the server updates the countdown time
    print(numberValue.Value) -- there's your countdown time
    textLabel.Text = tostring(numberValue.Value)
end)
1 Like

Remote Events should be your choice

Yes, you should be using Remote Events. While value objects will work, they don’t give you as much control as Remote Events do. (For example, you can control who the message is sent to easily)

I’ve made a repro with almost identical code, and it works.

--Local script under text label under screengui
local label = script.Parent
local event = game:GetService("ReplicatedStorage"):WaitForChild("ServerMessage")

event.OnClientEvent:Connect(function(message)
	label.Text = message
end)
--Server script under ServerScriptService
local event = game:GetService("ReplicatedStorage"):WaitForChild("ServerMessage")

--Game logic that starts intermission & stuff, but this is just a demo

for i = 30, 1, -1 do
	event:FireAllClients("A new round will begin in " .. i .. "s")
    --Note that by not sending the number, we allow other messages to be sent as well,
    --allowing this message system to be expanded easily
	wait(1)
end

Repro file: BasicServerIntermission.rbxl (20.9 KB)

The code you have should work fine, as long as the objects are in the right place. See if you can find anything you did significantly differently, but this works. Feel free to ask any questions you may have.

2 Likes

I tested your script and when a new player joins they don’t see anything at all. How do you make it so that everyone in the server sees the same thing at the same time, including new players?

I’m not sure what you mean. This works with multiple players.

However, the demo only runs the intermission timer once. If a player joins afterwards, no messages are being sent.

In a real scenario, you’d be sending messages every few seconds at least dictating how much time is left in the round, ect.

If you made a simple while true loop with the countdown, like

while true do

for i = 30, 1, -1 do
	event:FireAllClients("A new round will begin in " .. i .. "s")
    --Note that by not sending the number, we allow other messages to be sent as well,
    --allowing this message system to be expanded easily
	wait(1)
end

end

The issue would be resolved.

That’s why I added the --Game logic here comment

If you start a server with 2 players, they both see the countdown.

1 Like

Can you fire the remote event and receive it, every second, so that new players will be updated on the timer? Does it work like that?