Hello! I am Kamlkaze_Kid and I am trying to make an intermission where every player(Client) can see, and the text for each player is the same. I watched videos on RemoteEvents and read about them. I tried to make this work, but I think the Remote event is not firing. See for yourself:
-- Script in ServerScriptService
for i = 30, 1, -1 do -- this will count from 30 to 1 with -1 as the step.
game.ReplicatedStorage.RemoteEvent:FireAllClients(i) -- Tell the client the current time
wait(1)
end
-- local script, a parent of a text label
game.Workspace.Sound1:Play()
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(currenttime)
script.Parent.Text = "Welcome! A new map will be chosen in ".. tostring(currenttime)
end)
And there seems to be no error in output or script analysis. If you have questions, please ask.
Any errors? + I would like to mention ur system isnt effective. Instead of telling the client for every second to do something, u can just say to client u would like to start and then client handles counting down by himself.
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?