#tables giving nil on math.random

1 messages · Page 1 of 1 (latest)

unkempt chasm
#

im trying to make a system where you can get a random quest, but for some reason this thing returns nil. any ideas?

rare trench
#

Q2

#

Q3

#

Not 1 or 2 or 3

unkempt chasm
#

so how do i make it choose random quests

rare trench
#

Remove q

unkempt chasm
#

oh yea well i guess that works

#

thanks

rustic cairn
unkempt chasm
sage idolBOT
#

studio** You are now Level 8! **studio

unkempt chasm
#

tysm

rustic cairn
#

удачки

unkempt chasm
#

спасибо

ionic hull
#

Or try using 'Math.Round(Math.Random(1, 3))'

rare trench
ionic hull
#

math.round(math.random(1, 3)) instead of just math.random(1, 3)

rare trench
#

why

ionic hull
#

...

#

it works

#

so why argue

#

😦

rare trench
#

so does math.random()

#

without round

ionic hull
#

random decimal

#

like 2.9252395

rare trench
#

thats not how random works

#

it only gives full numbers

ionic hull
#

'tis

rare trench
#

unless u do ()

#

then its decimal ye

ionic hull
#

math.random is random

#

check it

rare trench
#

😭

ionic hull
#

in the command bar type 'print(math.random(1, 3))'

rare trench
#

u do it

#

am lazy

#
print(math.random(1, 3))
rare trench
odd sierraBOT
#
Program Output
3

ionic hull
#

aight bet

sage idolBOT
#

studio** You are now Level 4! **studio

ivory marten
#

yea so what you want to do is, if you want decimals, is:
minimumNumber - math.random() * (maximumNumber-minimumNumber)

rare trench
#
local minimumNumber = 5
local maximumNumber = 10
while true do
print(minimumNumber + math.random() * (maximumNumber-minimumNumber))
end
odd sierraBOT
#
Program Output
2.9801442805726

ivory marten
#

did i do minus oops

#

pressed the wrong button

ivory marten
odd sierraBOT
#
Program Output
7.5796537024574
5.6692583329492
9.5895640388014
7.2698188119178
7.744569280728
7.7963024632734
8.8643220274238
7.5249862517385
5.5738902844003
8.0594053898042
5.3491671144064
5.6452153617676
8.1320282915481
5.2887758581421
6.7383352760384
7.863423708
ivory marten
#

real

ionic hull
#

for me it does it in game but not when using the editor what

stoic solstice
#

if you want decimals you can use an object called Random with Random.new

#

and then call :NextNumber specifying the min and max

stoic solstice
ionic hull
#

😐

#

my bad

magic temple
#

дурашка полторашка 🌹

low pond
rare trench
#

Can we not like bump old posts

#

Pls