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

How do I make a system choose a variable based on rarity?

Hi there, I was wondering how I could make a script choose a varible depending on the rariety of being picked Lets say there's 5 Colours Red = 10% Blue = 10% Pink = 50% Brown = 5% Green = 25% How would I make a script choose one of them?

I'm really puzzled, I'd really like some help.

1 answer

✓ Accepted answer

obviously we must Use math.random for this, so look it up if you dont know how to use it.

We would start like this..

math.randomseed(tick())
DisNumba = math.random(1,100)
Color = Color3.new(0, 0, 0) -- currently white
-- I use  1 to one hundred because it is easier to deal with percents

if DisNumba >=1 and <=50  then
-- make color Pink
end

if DisNumba >=51 and <=60  then
-- make color red
end

if DisNumba >=61 and <=70  then
-- make color blue
end

if DisNumba >=71 and <=75  then
-- make color brown
end

if DisNumba >=76 and <=100  then
-- make color Green
end

Please accept this answer if it helped you, or comment if you have a question.

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