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: PlayerAdded script only working once

Previous Thread :: Next Thread 
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
03 Jan 2013 05:13 PM
So I made this script that moves the player to a random position once they enter, but all it's doing is moving the player to a random position once then when they reset they respawn at the center of the map. And this happens after every respawn.

script:

game.Players.ChildAdded:connect(function(plyr)
repeat wait() until plyr.Character
plyr.Character.Torso.CFrame = CFrame.new(math.random(1, 100), 7, math.random(1, 100))
end)

wiki.roblox.com
Report Abuse
ninja5566 is not online. ninja5566
Joined: 14 Jan 2009
Total Posts: 5233
03 Jan 2013 05:14 PM
game.Players.PlayerAdded:connect(function(plyr)
plyr.CharacterAdded:connect(function(char)
repeat wait() until plyr.Character
plyr.Character.Torso.CFrame = CFrame.new(math.random(1, 100), 7, math.random(1, 100))
end) end)
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
03 Jan 2013 05:15 PM
game.Players.ChildAdded:connect(function(plyr)
repeat wait() until plyr.Character
plyr.CharacterAdded:connect(function (character)
character.Torso.CFrame = CFrame.new(math.random(1, 100), 7, math.random(1, 100))
end)
end)

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】
Report Abuse
GnomeHarrison is not online. GnomeHarrison
Joined: 26 Oct 2012
Total Posts: 149
03 Jan 2013 05:17 PM
@ninja and jonah
You realize if you have the characteradded event, you don't need the repeat statement?
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
03 Jan 2013 05:17 PM
There's no need to wait for the Character, if the Character Loaded...

game.Players.PlayerAdded:connect(function(ply)
ply.CharacterAdded:connect(function(char)
char.Torso.CFrame = CFrame.new(math.random(1, 100), 7, math.random(1, 100))
end)
end)
Report Abuse
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
03 Jan 2013 05:19 PM
It stopped working once I removed the repeat until script.

wiki.roblox.com
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