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: Having an issue with math.random()?

Previous Thread :: Next Thread 
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:00 AM
Okay so, I have made a random spawning system, that spawns objects randomly inside the bounds of a part. It works perfectly in solo, but when I go into an online mode...

The objects start to sometimes spawn at the EXACT same spot as another. Which is pretty much impossible, out of all the other spots it can spawn in.

I am also generating a random seed for math.random()



Anyone know what could be the problem?



#code --jmt99
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
31 Dec 2015 02:02 AM
When are you setting the seed?
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:04 AM
At the top.

It's the 2nd line that ever executes in the script.

local start_time = tick()
math.randomseed(start_time)


#code --jmt99
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:08 AM
Here's some more information:

The objects that spawn that spawn on each other, are the next ones to spawn.

They don't like randomly spawn on the same object after lets say, 5 minutes.


#code --jmt99
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
31 Dec 2015 02:18 AM
math.randomseed(tick()%1*1e6)
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:21 AM
That's overkill, you should only need to put tick()

And just to be safe, I tried it, and it did not fix it.


#code --jmt99
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:26 AM
Could this be a problem of debounce?

Could my functions possibly be firing twice since it's on online mode with more lag etc?


#code --jmt99
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:29 AM
I mean like, my script performance percentage jumps a little as I am making threads (specifically with spawn() and not coroutines) with loops etc. Could this higher script performance at times cause this problem that I mentioned above?


#code --jmt99
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
31 Dec 2015 02:43 AM
Can't really help you without code.

I'd deliver my normal explanation of how to choose a good seed for math.randomseed but since that doesn't seem to be the issue here there is no point (though to be clear, it is not overkill, it solves some problems people have using tick() as a seed generator).
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:50 AM
I can't really post the code.

The spawning part is about 130+ lines + multiple modules, and you would need to know some other things to understand what is even going on in the script.

And I also don't want to post my source code.



But it's okay, If you need to the source code to help me, I guess I will have to fix it myself ;'(



But does anyone have any ideas that could help me at least?




#code --jmt99
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
31 Dec 2015 02:51 AM
we can't help from description alone.

good luck.
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 02:55 AM
I expected that's what people would say. I just maybe thought I would post to see if anyone had a problem similar to this before and had some suggestions on how to fix it.


#code --jmt99
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
31 Dec 2015 02:57 AM
It could be a thousand things. The most likely was that you set the randomseed more than once; if that was the case then my post would've fixed it.

We have no idea where your logic fails, and telling us that it works after 5 minutes and that you spawn multiple threads tells us nothing since we have no idea how time//threads factor into your code. Good luck.
Report Abuse
jmt99 is not online. jmt99
Joined: 27 Jul 2008
Total Posts: 4799
31 Dec 2015 03:01 AM
It's not that, so I guess that leaves 999 more solutions.

Good luck to me indeed.


#code --jmt99
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