Hey I've recently found a case script that works and have a few questions about it.
If you can answer my questions or perhaps have a better way to do this, I will greatly appreciate it
Code is below
local RarityI = { -- lower the rarer ["Common"] = 5, ["Uncommon"] = 3, ["Rare"] = 2, ["Legendary"] = 1 } local CrateInUse = false local function opencrate(Chance) if CrateInUse == false then CrateInUse = true script.Parent.Unboxing.Inner:ClearAllChildren() local Items ={} -- random Items local frametimes = math.random(20,50) local rewardbutton --win item --making the itemlist for _, Item in pairs(game.ReplicatedStorage.Items:GetChildren()) do local RarNumber = RarityI[Item.Rarity.Value] local Times = math.floor(RarNumber+Chance) -- gives bigger chance on better Items for num = 1,Times do table.insert(Items,Item) end end math.randomseed(tick()) --makes a seed for that second -- generating images for num = 1, frametimes+5 do local Item = Items[math.random(1,#Items)] local newFrame = script.Parent.Unboxing.SampleItem:Clone() newFrame.Visible = true newFrame.Parent = script.Parent.Unboxing.Inner newFrame.Icon.Image = Item.Image.Value newFrame.ItemName.Text = Item.Name newFrame.Position = UDim2.new(0,100*(num-1),0,0) newFrame.AnchorPoint = Vector2.new(0,0) if num == frametimes then rewardbutton = newFrame print (rewardbutton.ItemName.Text) end end for num = 1,(rewardbutton.Position.X.Offset - (255+math.random(-80,80)))/15 do for i,v in pairs(script.Parent.Unboxing.Inner:GetChildren())do v.Position = UDim2.new(0,v.Position.X.Offset - 15,0,0) if v.Position.X.Offset <= -100 then v:Destroy() end end --script.Tick:Play() wait(0.01 * 1.05 ^ (num-105)/2) end print(rewardbutton.ItemName.Text) end end opencrate(0)