iondriver
|
  |
| Joined: 18 Nov 2012 |
| Total Posts: 757 |
|
|
| 19 Feb 2015 12:45 PM |
Is there a limitation to the PlayerAdded and ChildAdded events that I am not aware of? I am using these events in a server script in playerGui. Is that a no no? It is not throwing any errors, it is just not firing. I have a print statement at the beginning of the called function, and it never prints. Any suggestions?
Thanks,
Iondriver |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2015 01:02 PM |
| Post the event code you have and the line that fires it. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2015 01:04 PM |
| You should only ever need Scripts in ServerScriptService, but if you don't want to go to the trouble for things like Touched and whatever, you can put them in bricks and such too. That's just my opinion. But you shouldn't need it in PlayerGui/StarterGui. ESPECIALLY with an event like PlayerAdded. |
|
|
| Report Abuse |
|
|
iondriver
|
  |
| Joined: 18 Nov 2012 |
| Total Posts: 757 |
|
|
| 19 Feb 2015 01:05 PM |
Here is the function
function CreateContact(Player) print("fired") Mycontacts = AdressBook:GetAsync() local found = true for i=1, #Mycontacts do if Mycontacts[i].Name == Player.Name then found = false end end if found then ContactObject.Name = Player.Name ContactObject.ID = Player.UserId MakeLabel(Player.Name) table.insert(Mycontacts, ContactObject) AdressBook:SetAsync(Player.UserId, Mycontacts) end
game.Players.PlayerAdded:connect(CreateContact) or game.Players.ChildAdded:connect(CreateContact)
I've tried both.
As far as I can tell, the function doesn't fire. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2015 01:05 PM |
| PlayerAdded may not work in PlayerGui as I just noticed that's where you have it. Now that I think of it, ChildAdded may not even fire either depending on what you're looking for on loading. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2015 01:07 PM |
| Yeah you need those out of the PlayerGui. ServerScriptService is your best bet. The player loads after they've been added to the player list and joined the game. Which is why your functions most likely wont even trigger half the time. |
|
|
| Report Abuse |
|
|
iondriver
|
  |
| Joined: 18 Nov 2012 |
| Total Posts: 757 |
|
|
| 19 Feb 2015 01:08 PM |
| My code is to make a pm system for multi-server communication. It is easier for me to have the code with the gui elements, but if that is causing the problem, I can switch things it over to global functions. Right now, the script is parented to a ScreenGui. |
|
|
| Report Abuse |
|
|
iondriver
|
  |
| Joined: 18 Nov 2012 |
| Total Posts: 757 |
|
|
| 19 Feb 2015 01:08 PM |
Ok, I just saw the replies.
I will give that a try. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2015 01:10 PM |
"It is easier for me to have the code with the gui elements, but if that is causing the problem, I can switch things it over to global functions. Right now, the script is parented to a ScreenGui."
I don't think you know what you're talking about...
⬡ |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2015 01:11 PM |
| You can still easily access the PlayerGui from the playeradded event, since an event would be triggered and continued for each player if needed. |
|
|
| Report Abuse |
|
|
iondriver
|
  |
| Joined: 18 Nov 2012 |
| Total Posts: 757 |
|
|
| 19 Feb 2015 01:24 PM |
| yup it worked. I feel like a noob now. |
|
|
| Report Abuse |
|
|