Why does :PlayerAdded not work on localscripts?

I understand that PlayerAdded works on the server, but what I don’t understand is that on the developer hub, it states that “Up until recently, this event didn’t work on the client (in Localscripts) but this has been changed”

I tried it on a local script, but it didn’t work. Can anyone explain what this means?

1 Like

I think thats “impossible” to work, because local scripts only see the player of the user and not other players.

1 Like

So then why does it say on the developer hub that it has been changed?

what is the point of a PlayerAdded event inside a local script anyways?

I just wanted to know whether this would work in a local script. Obviously, there’s no point of PlayerAdded in a local script.

Eh, whatever is on the client (You can test this by launching a LocalServer) localscripts can see, so that doesn’t make any sense when the client can see Players. Not to mention this does in fact work. I just tested it.

https://gyazo.com/4abfef0d550424489b99ca310c531bd9

Inside StarterPlayerScripts => LocalScript

game.Players.PlayerAdded:Connect(function()
	print("Hi!")
end)

There might also be reasons to use PlayerRemoving on Client depending on how you replicate stuff.

Hello!

Thanks for the reply, but unfortunately, this does not work for me. Is there anything that I am doing wrong?

Placed in StarterPlayer < StarterPlayerScripts

How did you test it? Did you try adding more players into the instance?

It works with other players, but why does it not with work just one player?

Because it’s PlayerAdded! It fires whenever other people to join since it’s a local script meaning it runs on the client that has joined.

2 Likes

More context to what @DevBeat said. Essentially, local scripts run after a client has joined the game, whilst server scripts run before a client has joined the game.

image

Players.LocalPlayer

This article is for newer developers or just developers in general to understand why it didn’t work!

1 Like