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

What's wrong with this random number selector?

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

✓ Accepted answer
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!

2 comments

0

oh, thanks

0

However, if you want to achieve randomness, I suggest a line before your function which says; math.randomseed(tick())

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