Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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"

0
Perfect. Thanks. joshmatt2244 28 — 6y
0
Wait, what if I want to do between -0.5 and 0.5 ? -_- Cuz IDK m8 joshmatt2244 28 — 6y
Ad

Answer this question