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

Why the PlayerAdded event wont execute?

game.Players.PlayerAdded:connect(function(player) -- Output won't tell what's the problem --
	print("Active")
	script.Parent.Text = (game.Players.NumPlayers)
end)

3 answers

✓ Accepted answer

Odd.

Try printing before the function, and then use

print("Searching Players")
game:GetService("Players").PlayerAdded:connect(function (player)
print(player.Name.." found")
end) 

Also, PlayerAdded does execute in Test Solo.

4 comments

0

Odd, It prints (Searching Players) but after the event nothing happens...

0

It works on my test solo. Perhaps it has something to do with your Players service properties, or even your Studio version and configuration.

0

I used it without PlayerAdded and it worked, Roblox changed it! :0

0

Erm, what? Without PlayerAdded? Can you comment the exact line, please?

I'm not sure on the specific details of this, but I know for a fact that when in studio, and you do a test run with a player, it's not going to read your player entering. It will only work if you are joining a server. How I like to test games sometimes is by minimizing studio, opening ROBLOX, and then going into my game. Don't forget to "Upload to ROBLOX as" and then every time you update it, to "Update to ROBLOX".

I read something about this error on the wiki, but don't take my word for it: I read a lot of wiki pages and often mix of the info, but hey - it's worth a shot.

2 comments

0

Thanks, but i'm joining in sever not in Solo Mode.

0

Sorry then, I'm not sure what to say.

Ive had problems with playeradded in the past.

A little workaround that should work:

game.Players.ChildAdded:connect(function(child)
	print("Active")
	script.Parent.Text = (game.Players.NumPlayers)
end)

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