generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: PlayerAdded not working

Previous Thread :: Next Thread 
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
12 Jan 2017 11:44 AM
Considering this piece of code:

function onPlayersChanged(player)
print("Done")
end

Players.PlayerRemoving:connect(onPlayersChanged)
Players.PlayerAdded:connect(onPlayersChanged)

"Done" is never shown. Breakpoints won't reach the onPlayerChanged method.

This is in a LocalScript. It does not work in studios nor online.

Anyone has an idea?

Thank you
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
12 Jan 2017 11:45 AM
This localscript is inside the playergui.
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
12 Jan 2017 11:45 AM
game.Players.PlayerRemoving:connect(onPlayersChanged)
game.Players.PlayerAdded:connect(onPlayersChanged)

Dont know if that will fix it
Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
12 Jan 2017 11:47 AM
Sorry, I forgot to mention that I added this at top :
local Players = game:GetService("Players")

I have also tried your way, but did not work :/

Thank you still
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
12 Jan 2017 11:50 AM
Is this in the Workspace or in PlayerScripts?
Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 11:52 AM
connect() is deprecated in favour of Connect()
But that should have no actual relevance to the fact it's not working for you.


Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
12 Jan 2017 11:53 AM
--LocalScript in StarterPlayerScripts local function playerAdded(player) print(player) end game.Players.PlayerAdded:connect(playerAdded) Output when player1 is in a game an player2 joins the lobby: 18:51:52.084 - ! Joining game ###################################### place 0 at localhost 18:51:52.090 - Connecting to localhost: 18:51:53.120 - Connection accepted from 127.0.0.1| Player2 Note that you will have to start 2 players in order for 1 event to trigger.
Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 11:54 AM
Wait, this is in a local script? Surely you can't access this sorta stuff if you're using FE.


Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
12 Jan 2017 11:55 AM
f Hashing system I am going crazy.

-LocalScript in StarterPlayerScripts

local function playerAdded(player)
print(player)
end

game.Players.PlayerAdded:connect(playerAdded)

Output when player1 is in a game an player2 joins the lobby


Player2
Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 11:56 AM
Why would you need this event in a local script. Surely you can do this from a server script and fire all clients with a remote event if you need to do so.


Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
12 Jan 2017 11:58 AM
@BIueNarwhaI connect still works fine and will probably continue working fine for at least a couple of years I think, and of course you can access that kind of stuff from the client with FE enabled.

The client has to know when a player joins the lobby too right?
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
12 Jan 2017 11:59 AM
Why would you let the server handle something the client can perfectly do by itself?

Except if you are working with protected values ofcourse
Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 11:59 AM
I was just thinking surely if you have access to that event you'd have access to the entire Player service but meh. You're probably right.


Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 12:02 PM
crate, read the Notes section in this article

http://wiki.roblox.com/index.php?title=API:Class/Players/PlayerAdded


Report Abuse
crate109 is not online. crate109
Joined: 24 Nov 2010
Total Posts: 315
12 Jan 2017 12:06 PM
I will be using remote then. Thank you guys!
Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
12 Jan 2017 12:07 PM
Y tho...?

The code I provided works perfectly fine
Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 12:07 PM
The Notes section mentions an easy way to work around the issue client sided. But I'd suggest using remote functions anyway if it's just one simple part of a bigger game.


Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 12:08 PM
pket, you can't print a player instance


Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 12:09 PM
remote events*
It's been a long day.


Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
12 Jan 2017 12:10 PM
@BIueNarwhaI

What are you talking about?

Ofcourse I can print a player object.

And even if I couldn't the event still gets triggered when another player joins the game, like I explained
Report Abuse
BIueNarwhaI is not online. BIueNarwhaI
Joined: 10 Apr 2012
Total Posts: 866
12 Jan 2017 12:13 PM
What am I talking about. I should go sleep. My apologies.
Just tested it, you can print a player instance.


Report Abuse
pketny is not online. pketny
Joined: 27 Dec 2010
Total Posts: 1162
12 Jan 2017 12:14 PM
No worries, sleep well :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image