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

How do i randomize between 0 and 0.8?

Asked by 2 years ago

I wanted to make part change its transparency between 0 and 0.8 but for some reason it only selects 0

Here is my script

while wait(0.1) do
    local randomize = math.random(0, 0.8)
    print(randomize)
end

1 answer

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago
local randomize = math.random(0, 8) / 10
-- or
local randomize = Random.new():NextNumber(0, 0.8)
0
math.random only generates whole numbers (0, 1, 2, 3, 4) not numbers like 2.22, the only exception is math.random() which generates random number from 0 to 1 imKirda 4491 — 2y
Ad

Answer this question