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 Event Bug and Fix

Previous Thread :: Next Thread 
truman89 is not online. truman89
Joined: 18 May 2008
Total Posts: 531
15 Jan 2014 12:40 PM
Hello. Some of you already know about this bug. If you try to use the PlayerAdded event in test mode, no matter what you put in it, the event will not work. This makes it hard to test out scripts that may use the PlayerAdded event, such as scripts with Automatically Loading data persistence. I have figured out an extremely simple fix for this.

1. Go to Tools>Test>Start Server, or just press F7 on your keyboard.
2. Go to the new server window you just opened up, and wait for it to load.
3. Go to Tools>Test>Start Player, or press Alt+F7. Your script should now work like any other script would.

Also, I'm new to this forum, and I would like to get to know the community around here a little more. Can someone tell me about some of the more active people around here? I already know about Sorcus, who seems pretty cool. Anyone else I should look out for?
Report Abuse
Merely is not online. Merely
Joined: 07 Dec 2010
Total Posts: 17266
15 Jan 2014 12:48 PM
The PlayerAdded event works in play solo, it just doesn't fire because the player joins the game before any of your scripts run.

The best way to deal with this is to loop through all existing players when your script is run, and run your onPlayerAdded function for them. Example:

function onPlayerAdded(player)
--do stuff
end

--there might be existing players, so let's handle them
for _,player in pairs(game.Players:GetPlayers()) do
onPlayerAdded(player)
end

--now hook up to the event
game.Players.PlayerAdded:connect(onPlayerAdded)
Report Abuse
truman89 is not online. truman89
Joined: 18 May 2008
Total Posts: 531
15 Jan 2014 12:51 PM
I see what you're saying, but this way is much faster and more efficient, plus you don't need that extra code.
Report Abuse
dogwarrior24 is not online. dogwarrior24
Joined: 10 Nov 2010
Total Posts: 1401
15 Jan 2014 12:53 PM
Merely = another active col person
Report Abuse
truman89 is not online. truman89
Joined: 18 May 2008
Total Posts: 531
15 Jan 2014 01:01 PM
Oh yes, I know about Merely, I just call him Rich Guy. I'm pretty sure he has the most Robux on the website(Legit tho). I just didn't know he went on these forums. Heck, I didn't even know he was the one who posted until you brought it to my attention. Imma so stewpid.
Report Abuse
Merely is not online. Merely
Joined: 07 Dec 2010
Total Posts: 17266
15 Jan 2014 01:03 PM
Start Server -> Start Player is a lot laggier because you have to have two windows open, as opposed to one play solo window.
Report Abuse
truman89 is not online. truman89
Joined: 18 May 2008
Total Posts: 531
15 Jan 2014 01:06 PM
If you have a slow comp, then you can just allocate more memory to the server through the Ctrl+Alt+Delete windows command. But people with better computers like myself have no problem with lag. As long as you have decent graphics and around 4 to 6 GB of memory, you should be good.
Report Abuse
TheLuaWeaver is not online. TheLuaWeaver
Joined: 09 Feb 2010
Total Posts: 1504
15 Jan 2014 02:25 PM
First of all, I don't know anyone here who didn't know about server/player as opposed to solo. Merely has a method which is safer in both testing and live servers; if something slows down the execution of your script and the event isn't fired, that loop will catch it.

You should always do that.

~LuaWeaver; Programmer, gamer, developer.
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