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: How can I randomize this number inbetween numbers?

Previous Thread :: Next Thread 
BloxaBrick is online. BloxaBrick
Joined: 24 Oct 2009
Total Posts: 25309
01 Nov 2017 01:36 PM
SparksSEffect.PlaybackSpeed = 1

Instead of 1, how do I get it to be 0.9 through 1.2?
Report Abuse
MiAmasKafon is not online. MiAmasKafon
Joined: 12 Jul 2017
Total Posts: 135
01 Nov 2017 01:43 PM
SparksSEffect.PlaybackSpeed = math.random(0.9, 1.2)
Report Abuse
nextgenplatform is not online. nextgenplatform
Joined: 27 Feb 2017
Total Posts: 797
01 Nov 2017 01:44 PM
= math.random(0.9,1.2)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
01 Nov 2017 01:45 PM
math.random(90, 120)/100
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
01 Nov 2017 01:47 PM
math.randomseed(tic)

function between (L, H)

return math.random() * (H - L) + L

end



between (.9, 1.2)
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
01 Nov 2017 01:51 PM
*errors math.randomseed(tick()) function between (L, H) return math.random() * (H - L) + L end ##### = between (.9, 1.2)
Report Abuse
BloxaBrick is online. BloxaBrick
Joined: 24 Oct 2009
Total Posts: 25309
01 Nov 2017 01:55 PM
Kafon's worked. Thanks.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
02 Nov 2017 03:27 AM
It doesn't, it does the same thing as your original code, the value will always be 1.
Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
02 Nov 2017 04:55 AM
Chimmi is actually right, math.random will get an integer like 1,2,3. Thats why math.random(.9,1.2) will always get 1.
Report Abuse
0supadude0 is not online. 0supadude0
Joined: 11 Aug 2010
Total Posts: 649
02 Nov 2017 05:42 AM
Or

0.9 + 0.3*math.random()
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
02 Nov 2017 06:29 AM
^ that's not a thing
Report Abuse
annabet_h is not online. annabet_h
Joined: 13 Mar 2016
Total Posts: 1475
02 Nov 2017 06:31 AM
math.random(10)*.1
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Nov 2017 06:33 AM
"^ that's not a thing"
Did you try it? I could be wrong, but I don't see anything wrong with it.

If you don't want to do the math yourself, here's a good function.

local function random(a, b)
return a+(b-a)*math.random()
end

print(random(0.9, 1.2))

Same math as his, actually.
0.9+0.3*math.random()
Yeah, his code should work perfectly.


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
02 Nov 2017 06:44 AM
It looked cool, so I believed it, then questioned it.
I tried it in rep.lit and got values in excess of 1, but maybe I did something wrong, let me check again

*doot doot time passes*

So I tried it again like this
min,max = .3,.9
print(max+min*math.random())

and got these results

0.98
1.06
1.04
1.08
1.00
1.05
1.18
1.17
1.09
1.11

did I do something wrong? it's pretty much exactly what he said, unless there's some other proceedure I was supposed to assume from it.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Nov 2017 06:50 AM
That isn't max+min*r, that's min+(max-min)*r

The value ranges from .9 to (.9 + .3) Required extra sentence here for filter dodging.
Now, the upper constraint is 1.2, as originally specified in the OP's example post.

"Instead of 1, how do I get it to be 0.9 through 1.2?"
That is what the values are.

If you wanted to get a number between 4.2 and 6.1, it would be
4.2 + (6.1 - 4.2)*r
Required extra sentence here for filter dodging.
4.2 + 1.9*r


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
02 Nov 2017 06:56 AM
Oh!
My issue is that I just assumed .3 was the min and .9 was the max without referring back to the OP, where the min was .9 and the max was 1.2

Report Abuse
Luckyxero is not online. Luckyxero
Joined: 26 Feb 2014
Total Posts: 505
02 Nov 2017 06:56 AM
-_- noobs

math.random(90, 120) / 100
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
02 Nov 2017 06:58 AM
chim already gave that answer
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Nov 2017 06:59 AM
"math.random(90, 120) / 100"
Noob.

local function lerp(a, b, c)
c = c or math.random()
return a+(b-a)*c
end

lerp(.9, 1.2)


Seriously get on our level.


Report Abuse
Kiriot22 is not online. Kiriot22
Joined: 19 Jul 2015
Total Posts: 226
02 Nov 2017 07:01 AM
A nice discussion about math.random we have right there.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Nov 2017 07:15 AM
"A nice discussion about math.random we have right there."
It's not a discussion if my way is the only correct way to do it, and everyone else is flat out wrong.


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
02 Nov 2017 07:16 AM
i mean, if we want to get technical that's still a discussion
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Nov 2017 07:18 AM
It's not a discussion. If debate class taught me anything, it's that you can't have a discussion when I won't listen to reason.


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
02 Nov 2017 07:19 AM
are you emulating me lol
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Nov 2017 07:23 AM
Nope, why emulate someone like you when I can emulate myself?


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