Advertisement
Quoteory

Serial Generator Lua

Sep 12th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. local random = Random.new()
  2. local randomMin, randomMax = 100, 99999
  3.  
  4. local InventoryService = {}
  5.  
  6. function InventoryService.getRandomNumber()
  7.     return random:NextInteger(randomMin, randomMax)
  8. end
  9.  
  10. function InventoryService:GetUniqueSerial(Inventory)
  11.    
  12.     local armors = Inventory["Armors"]
  13.     local weapons = Inventory["Weapons"]
  14.    
  15.     local uniqueSerial
  16.    
  17.     local function recursion()
  18.         uniqueSerial = self.getRandomNumber()
  19.         if armors[uniqueSerial] or weapons[uniqueSerial] then
  20.             recursion()
  21.         end
  22.     end
  23.    
  24.     recursion()
  25.    
  26.     return uniqueSerial
  27.    
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement