Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local debounce = {}
- local function rand(tbl)
- local rn = Random.new()
- local sum = 0
- for i = 1, #tbl do
- sum = sum + tbl[i].Weight
- end
- local num = rn:NextNumber(0, sum)
- for i = 1, #tbl do
- if num <= tbl[i].Weight then
- return tbl[i]
- end
- num = num - tbl[i].Weight
- end
- end
- local tabl = {
- {Obj = "Common", Weight = 44},
- {Obj = "Uncommon", Weight = 32},
- {Obj = "Rare", Weight = 21},
- {Obj = "Epik", Weight = 10},
- {Obj = "Legendary", Weight = 2},
- {Obj = "Mythic", Weight = 0.1},
- {Obj = "The Unobtainable", Weight = 0.0001},
- }
- local tabl2 = {
- ["Common"] = {
- {Obj = "Gun", Weight = 30},
- {Obj = "Sword", Weight = 20},
- {Obj = "Pie", Weight = 10},
- {Obj = "Corn", Weight = 5},
- },
- ["Uncommon"] = {
- {Obj = "Green greene gun", Weight = 20},
- {Obj = "Sock", Weight = 20},
- {Obj = "Big bone", Weight = 20},
- {Obj = "Hello", Weight = 20},
- },
- ["Rare"] = {
- {Obj = "Gobstopper", Weight = 10},
- {Obj = "Melodic Rifle", Weight = 20},
- {Obj = "Annoyingly Common Coin", Weight = 50},
- {Obj = "Severed Leg", Weight = 20},
- },
- ["Epik"] = {
- {Obj = "Tom's mini cannon", Weight = 30},
- {Obj = "Golden Plate", Weight = 10},
- {Obj = "Killer bean", Weight = 20},
- {Obj = "Gross Hankerchief", Weight = 30},
- },
- ["Legendary"] = {
- {Obj = "Bazooka", Weight = 20},
- {Obj = "Thanos guantlet", Weight = 10},
- {Obj = "Echoer", Weight = 30},
- {Obj = "Platinum Plate", Weight = 8},
- },
- ["Mythic"] = {
- {Obj = "Reality Rifle", Weight = 10},
- {Obj = "Sword Requiem", Weight = 20},
- {Obj = "Headhunter", Weight = 30},
- },
- ["The Unobtainable"] = {
- {Obj = "The One and Only.", Weight = 100}
- },
- }
- game.ReplicatedStorage.CaseEvent.OnServerInvoke = function(player)
- if not debounce[player] then
- debounce[player] = true
- coroutine.resume(coroutine.create(function()
- wait(0.1)
- debounce[player] = false
- end))
- local i = rand(tabl)
- local i2 = rand(tabl2[i.Obj])
- return {i,i2}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement