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 » Scripting Helpers
Home Search
 

Re: LoadCharacter() and CharacterAdded: weird behaviour

Previous Thread :: Next Thread 
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
17 Jul 2014 03:27 PM
local RespawnTime = 3
game:GetService("Players").PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character:WaitForChild("Humanoid").Died:wait()
wait(RespawnTime)
Player:LoadCharacter()
print(Player.Name.." spawned.")
end)
Player:LoadCharacter()
end)

Until recently, there was nothing wrong with this script.
But for some reason, now I am getting this error:

22:22:15.010 - WaitForChild called on an Instance that is not in a DataModel.
22:22:15.011 - Script 'ServerScriptService.Service_Respawns', Line 5
22:22:15.011 - Stack End

The CharacterAdded event fires when the character is added, no?
So the character should have loaded, and I should not be getting this error.
I even tried adding a wait() after the CharacterAdded line. No success.
If anyone knows what is wrong, please post below. Thanks.

~The herp lerped a derp~
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
17 Jul 2014 03:57 PM
This is kinda breaking my game, so... uh... Bump? :D

~The herp lerped a derp~
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
17 Jul 2014 04:15 PM
I don't think you can use variables to wait.

And if you can, there needs to be "" around the 3, I believe.
Report Abuse
MrTucan1996 is not online. MrTucan1996
Joined: 19 Aug 2009
Total Posts: 5994
17 Jul 2014 04:18 PM
No @Kross
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
17 Jul 2014 04:18 PM
@Tusc

Thanks for posting to just tell me i'm wrong instead of helping the OP.
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
17 Jul 2014 04:20 PM
You can use events as an argument for the wait method. Example:
game:GetService("RunService").Heartbeat:wait()

~The herp lerped a derp~
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
17 Jul 2014 04:22 PM
Sorry, I really didn't know that. I started scripting two weeks ago, and I just tried helping.
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
19 Jul 2014 07:53 AM
2 days bump wooooo

~The herp lerped a derp~
Report Abuse
super10099 is not online. super10099
Joined: 30 Jan 2010
Total Posts: 1102
19 Jul 2014 07:56 AM
diesable character auto load?

game:service'Players'.CharacterAutoLoads = false
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
19 Jul 2014 07:59 AM
@super
Already done.
And that doesn't have anything to do with the error.

~The herp lerped a derp~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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