Remote event is not firing on player join

Hello, I am trying to fire a remote event for when a player joins. This is my code

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	game.ReplicatedStorage.RESET:FireServer()
	print("test")
end)

This is a LocalScript in the workspace and the print function isn’t even working so I know its not an issue with the remote event but rather that its never even being loaded in.

is this a local script?
if yes then that is the problem

1 Like

I tried making it an actual script but you can only fire remote events from the client

no remote events can fire in any script

Why would you fire an event if it’s already on the server? If you want another script to activate, use BindableFunctions. Also, as @D0RYU rightfully said, it has to be on the server, not on the client (i.e. a normal script).

You can read more about BindableFunctions here

Time to reference this again:

You can’t use FireServer() and OnClientEvent on the Server Side, as that’s only possible for the client

You CAN however use a FireClient() function if that’s what you mean

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	game.ReplicatedStorage.RESET:FireClient(player)
	print("test")
end)

Also,

LocalScripts cannot run in the workspace, you have to reference them from the client’s perspective (Change it to a server script instead in ServerScriptService)

1 Like

The problem is your using a Local script, The local script wont run because its on the client and cant see when a player joins. I would transfer the code to a server script and it should run just fine…

Clients are capable of detecting when a player joins the server.

game:GetService("Players").PlayerAdded:Connect(function(player)
	print(player)
end)

image

AFAIK it probably detects itself otherwise Player3 would be printed two times

If what you’re trying to achieve is to reset everytime a player joins, you could do that by using a PlayerAdded event in a server-side script.

Create a server-side script and put it in ServerScriptService. After that, enter the code below:

 game.Players.PlayerAdded:Connect(function(player)
     -- Code to reset
 end)

If you’re trying to reset the player everytime it joins, you could do the following:

 game.Players.PlayerAdded:Connect(function(player)
     player.CharacterAdded:Connect(function()
         player:LoadCharacter()
     end)
 end)

It only detects other player’s joining since the script loads in after you have.

Local scripts are cloned on each client, so 2 for Player2 and Player3, so if they really detected other players, Player3 should print twice since there’s two scripts “detecting” (P2 and P3) players. Either way it’s better to do this on the server

The output is from the client’s own output. It only prints each player one time because the output is local to that player only. Aside from that, I do agree that stuff that needs to be done on the server should be handled solely by a server script.