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

What's wrong with this random number selector?

Asked by 7 years ago

what's wrong with this random number selector?

local value = script.Parent.Value

function random()
    value.Value = math.random(1,2,3,4,5,6,7,8)
    wait(1)
    value.Value = 0
end

script.Parent.ClickDetector.MouseClick:connect(random)

I actually don't know what's wrong and this is my first time using math

1 answer

Log in to vote
0
Answered by
65225 80
7 years ago
local value = script.Parent.Value

function random()
    value.Value = math.random(1,8)
    wait(1)
    value.Value = 0
end

script.Parent.ClickDetector.MouseClick:connect(random)

math.random Does not change the value to any of the numbers listed. You have to use a range of numbers, not individual.

Hope it helped!

0
oh, thanks KatsuneSniper 31 — 7y
0
However, if you want to achieve randomness, I suggest a line before your function which says; math.randomseed(tick()) aztec_glory 63 — 7y
Ad

Answer this question