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: Player Added and ChildAdded events not working

Previous Thread :: Next Thread 
iondriver is not online. 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
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
19 Feb 2015 01:02 PM
Post the event code you have and the line that fires it.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is not online. 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
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
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
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
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 is not online. 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 is not online. 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
DeviousDeviation is not online. DeviousDeviation
Joined: 28 Dec 2010
Total Posts: 9306
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
Legoman654 is not online. Legoman654
Joined: 05 Jun 2008
Total Posts: 534
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 is not online. 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
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