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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Trouble with math.random, coroutines and loops

Previous Thread :: Next Thread 
Jake0128 is not online. Jake0128
Joined: 09 Aug 2013
Total Posts: 1631
25 Oct 2013 07:40 PM
It gets caught in a strange loop where it just infinitely keeps generating numbers and not doing anything with them.... this is inside a coroutine : / ideas?

xgen = 0
ygen = 0
zgen = 0

for i = 1, 10 do
factor = math.random(1, 1000)
print(factor)
if factor <= 600 then
ore2 = game.Lighting.dirt:clone()
elseif factor >= 601 and factor <= 733 then
ore2 = game.Lighting.iron:clone()
elseif factor >= 734 and factor <= 870 then
ore2 = game.Lighting.lead:clone()
elseif factor >=871 and factor <= 935 then
ore2 = game.Lighting.copper:clone()
else
ore2 = game.Lighting.silver:clone()
end
ore2.CFrame = CFrame.new(xgen, ygen, zgen)
xgen = xgen + 5
wait()
end
Report Abuse
Jake0128 is not online. Jake0128
Joined: 09 Aug 2013
Total Posts: 1631
25 Oct 2013 07:53 PM
bump, this should be so simple but I dont get it x_x
Report Abuse
orangegreenblue is not online. orangegreenblue
Joined: 04 Sep 2010
Total Posts: 10906
25 Oct 2013 07:58 PM
The parent of an object cloned with the Clone method is set to nil by default.

You need to manually set the parent of the cloned instance.
Report Abuse
Jake0128 is not online. Jake0128
Joined: 09 Aug 2013
Total Posts: 1631
25 Oct 2013 08:00 PM
wat is wrong with me qq
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