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: Resetting value for next time

Previous Thread :: Next Thread 
sunday1520 is not online. sunday1520
Joined: 23 Aug 2012
Total Posts: 693
29 Sep 2013 03:43 PM
for i,v in pairs(game.Players:GetChildren()) do
table.insert(players,v.Name)
end
d=-73.4
for i,v in pairs(players) do
chr=game.Workspace:findFirstChild(v)
chr.Torso.CFrame=CFrame.new(d,8,-93.9)
d=d+15
end


So thats the script im currently using. It takes all players, then moves each character to a spot 15 studs apart. Works perfectly fine. That is, until it happens again. The players end up in the position 15 studs after the last person of the last time they were all moved. I believed by having "d" defined just before the loop it would reset the value of d. Im not quite sure why it doesnt work. Anyone see the problem?
Report Abuse
Andrew1234567mmm is not online. Andrew1234567mmm
Joined: 14 Oct 2009
Total Posts: 691
29 Sep 2013 03:45 PM
Your d=d+15 is before they teleport so it adds 15 when its done
Report Abuse
Andrew1234567mmm is not online. Andrew1234567mmm
Joined: 14 Oct 2009
Total Posts: 691
29 Sep 2013 03:45 PM
i mean after
Report Abuse
XAXA is not online. XAXA
Joined: 10 Aug 2008
Total Posts: 6315
29 Sep 2013 03:48 PM
for i,v in pairs(game.Players:GetChildren()) do
table.insert(players,v.Name)
end

for i,v in pairs(players) do
chr=game.Workspace:findFirstChild(v)
chr.Torso.CFrame=CFrame.new(d,8,-93.9)
d=d+15
end
d=-73.4

Did you try putting it after the loop?
Report Abuse
sunday1520 is not online. sunday1520
Joined: 23 Aug 2012
Total Posts: 693
29 Sep 2013 03:50 PM
agh nevermind guys. I figured it out. Its the fact that it re-adds the players again to the player table. I just put a line resetting the "players" table that the first loop adds to. Now it works just fine.
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