Remote Event is not Firing!

server:

game:GetService("ReplicatedStorage").RemoteEvent:FireAllClients()

client:

game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(function()
    for i = 30, 1, -1 do
        script.Parent.Text = "Welcome! A new map will be chosen in ".. i
        wait(1)
    end
end)

I think sth like this

Then, why not check? Add print statements in the script & localscript to help narrow down potential issues.

pretty sure it works like

                                  '''
                   script.Parent.Text = "Welcome! A new map will be chosen in"..tostring(currenttime) 

‘’‘’

Maybe there is an issue with your GUI. I tried the code, it worked for me.

Any local scripts should use WaitForChild, so use

ReplicatedStorage:WaitForChild("RemoteEvent")

Some things load after local scripts run.

You don’t have to fire a remote for every client in the game 30 times for a countdown, just call :FireAllClients() once and connect the listener to a function which counts from 30 on the client.

local remote = game:GetService("ReplicatedStorage").RemoteEvent

local function OnClient()
      print("executing")
      for i = 30, 1, -1
      script.Parent.Text = "Welcome! A new map will be chosen in ".. i
   end
end

remote.OnClientEvent:Connect(OnClient)

Check your output, ‘executing’ should print once the event fires for clients.


Calling tostring() here isn’t necessary by the way, concatenating a number and string is legal.

Not always true, only when you’re sure where you’re indexing from will replicate before other objects (i.e through a LocalScript in ReplicatedFirst) otherwise anything under ReplicatedStorage replicates before LocalScripts execute.

1 Like

Unfortunately, the code doesn’t work and it doesn’t print “executing” either, but thanks for your trying!

It should work and you’re definitely doing something very incorrect here.
What scripts are you using for firing and receiving?

Use a ServerScript in ServerScriptService for firing for all clients (make sure players actually loaded in by that time) and a LocalScript containing the listener.

                                                                            '''
             --severscript
            game.ReplicatedStorage.Remote:FireAllClients()
        
           --local script
           local remote = game:GetService("ReplicatedStorage").RemoteEvent

     local function OnClient()
  print("executing")
  for i = 30, 1, -1
  script.Parent.Text = "Welcome! A new map will be chosen in ".. i
 end

end

     remote.OnClientEvent:Connect(OnClient)
      '''

I can’t quite understand by the formatting, but you left out the parenthesis while attempting to call Remote:FireAllClients().

Additionally, make sure players actually exist in the game before trying to fire for clients.
You only need to fire when you have to, but for perceiving it’s effect, try yielding at the beginning of the server script

wait(10)
-- code
-- assuming by 10 seconds you'll have loaded in

And any errors at all?

Edit: I also thought you said the remote was called ‘RemoteEvent’??

You’re trying to fire an inexistent event from the server and listening for another.

For some reason it still doesn’t work

Ok so I tried this:

                  '''
    -- SeverScript
   wait(5)  --wait for players to load 
    game.ReplicatedStorage.RemoteEvent:FireAllClients() 

   -- local script
   game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
   for i = 30,1,-1 do
   script.Parent.Text = "Welcome! A new map will be chosen in " .. i
   end

end)
‘’’

But it goes from 30 to 1 in less than seconds. How can i fix this?

You don’t have a wait(1), that’s why.

Do this instead:

for i = 30,1,-1 do
   script.Parent.Text = "Welcome! A new map will be chosen in " .. i
   wait(1)
end
1 Like

Will that work on every client in the game?

Yes I know it will work, but will all clients see the same text at the same time?

If you’re displaying text from the client then no, unless all players were present at the time FireAllClients() was called all of them will see different text, to get over this try to keep the time synced on the server and as players join, show them the current numbers thnat need to be shown.

I also need to do this for my game also, so do you just change the text in the StarterGui or something?

How would you do that? I’m new to scripting.

also when the text changes, do I have to fire and receive the remote event again?

Also, Isn’t it easier to put the text in a server script so you dont have to fire and receive a remote event?