Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is math.random() not working in this line of code? randomrandomrandom

trace.CFrame = CFrame.new(hole.CFrame.p, position) * CFrame.new(0 + math.random(0,0.8), 0, -distance/2)

All it does is go back and forth from 0 to 0.8 and I want it to select a number between 0 and 0.8

UM HELP MEH.

randomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandomrandom

1 answer

When doing something like math.random(1, 100), all the numbers will turn out as whole numbers, which in some cases, just isn't enough. However, if you did this, then the numbers would be random non-integers between 1 and 100, including decimals:

math.randomseed(tick())
 
for _ = 1, 10 do
	print(math.random()*100)
	wait(1)
end

Source "Even more random"

2 comments

0

Perfect. Thanks.

0

Wait, what if I want to do between -0.5 and 0.5 ? -_- Cuz IDK m8

This discussion is preserved as it was. New answers, comments, and votes are closed.