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

Why Does The Remote Event Fire For One Player?

##What is the problem?

I have a server. There is one player. Then, then, another player joins. The problem is that when I use the remote event, it only fires for the player that was already there, but, for the other player that joined, it doesn't work.

Server

--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
--\\ Network Data
local remoteEvent = repStorage:WaitForChild("RemoteEvent")

remoteEvent:FireAllClients()

Client

--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
--\\ Network Data
local remoteEvent = repStorage:WaitForChild("RemoteEvent")

remoteEvent.OnClientEvent:Connect(function()
	local gui = Instance.new("ScreenGui")
	gui.Parent = script.Parent -- assuming the parent of this client script is PlayerGui
	local txt = Instance.new("TextLabel")
	txt.Text = "Remote Fired"
	txt.Parent = gui
end)

You see, I am working with the Client(see the GUI's).

1 answer

The problem here is your server; you made it fire all clients, but only once, so when the other player joins, the event doesn’t fire again and the player doesn’t receive the signal. To resolve this, use the PlayerAdded event of the Players, which fires everytime a player joins:

--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--\\ Network Data
local remoteEvent = repStorage:WaitForChild("RemoteEvent")

Players.PlayerAdded:Connect(function(plr)
     remoteEvent:FireClient(plr, nil)
end)

You also don’t need to use FireAllClients, just fire once to the player who just joined.

If it works for you, please upvote and accept this answer!

6 comments

0

yup, thats what i was gonna put.

0

I'll test it out

0

Well, when the player joins, it is supposed to have the same thing. For example, if a player joined and it was counting down from 100 to 0. Let's say it is at 73, when another player joins. It should be 73, not from the beggining

0

This is definately not my problem. You didn’t include the countdown script or anything. This script of yours is just for creating a gui I assume

0

But it looks like you have a lot of syncing problem, try storing the time on the server then fire it to the clients

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