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
|
  |
| Joined: 24 Nov 2010 |
| Total Posts: 315 |
|
|
| 12 Jan 2017 11:45 AM |
| This localscript is inside the playergui. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 12 Jan 2017 11:50 AM |
| Is this in the Workspace or in PlayerScripts? |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
|
| 12 Jan 2017 12:07 PM |
Y tho...?
The code I provided works perfectly fine |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 12 Jan 2017 12:08 PM |
pket, you can't print a player instance
|
|
|
| Report Abuse |
|
|
|
| 12 Jan 2017 12:09 PM |
remote events* It's been a long day.
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 1162 |
|
| |
|