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 6 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
6 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 — 6y
0
However, if you want to achieve randomness, I suggest a line before your function which says; math.randomseed(tick()) aztec_glory 63 — 6y
Ad

Answer this question