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!