Here is the script:
local ranGen = Random.new(tick())
local lSPC = 1
local rSPC = 2
local uSPC = 100
local oSPC = 350
local function randomBoxChooser()
local ranNum = ranGen:NextInteger(1, 1000)
print(ranNum)
if ranNum >= oSPC then
return "Ordinary Box"
elseif ranNum >= uSPC then
return "Uncommon Box"
elseif ranNum >= rSPC then
return "Rare Box"
elseif ranNum >= lSPC then
return "Legendary Box"
end
end
I originally had a for loop going up to a thousand and putting in names of the boxes based on probability but that seemed really inefficient to me so I changed it. Just wanted to know if this was the most efficient way. Also later on I Clone the box into workspace at a random CFrame. Now I have read an article on how we should set the parent last and was wondering if that applied to CFrame as well. Here is an example of what I mean:
local box = serverBox:Clone()
box.Parent = game.Workspace
box.CFrame = location
Hope you guys can help. Thanks!

4 comments
It's not a bad system, but there is one flaw, you are checking if each number is greater than the number you specified, on line 11 you're saying if the number is greater than 1 it will return "Ordinary Box" which will always be true since your indexing a number 1-1000. So you should do "if ranNum >= oSPC and ranNum < uSPC" and so forth.
No I am not. You must not have read my code very carefully.
oSPC = 350
on line five