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)
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.
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
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.
'''
-- 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?
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.