Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

FireServer Not Working?

Asked by 8 years ago

The problem is that it does not print anything, I have no idea why though

its a local script in the startergui

no output erros


game.Players.PlayerAdded:connect(function(player) print(134315) game.Workspace.RemoteServer.ActivateRespawn:FireServer() print(134315) end)

1 answer

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

The problem is that the player is added to the server before the local script is loaded, and therefore the PlayerAdded event is never fired (unless someone else joins the server afterwards).

With what you have now, the event would fire in every local script in every player for every additional player that joins. So if the 100th player joins the server, ActivateRespawn will fire 99 times, once for every player that was in the game. I'm reasonable sure that this isn't what you want to happen.

I assume that you just want the function to fire when the player joins the game, which can be done without an event and just one line. Because the local script is added to the player's PlayerGui when they join the game, that can suffice as your "PlayerAdded" event.

LocalScript

game.Workspace.RemoteServer.ActivateRespawn:FireServer()

Please correct me if this assumption is wrong.

Ad

Answer this question