SHARE
TWEET

Untitled

xaviersvt Aug 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local Scrap = {
  2.     {"Scrap1", 50},
  3.     {"Scrap2", 25},
  4.     {"Scrap3", 15},
  5.     {"Scrap4", 5},
  6.     {"Scrap5", 1},  
  7. }
  8.  
  9. while wait(1) do
  10. local maxVal = 0
  11. for pos,val in next, Scrap do
  12.     maxVal = maxVal + val[2]
  13. end
  14.  
  15. local function GetRandomItems (num)
  16.     local Count = 0
  17.     for pos,val in next, Scrap do
  18.         Count = Count + val[2]
  19.         if num <= Count then
  20.             return val[1]
  21.         end
  22.     end
  23.     return nil
  24. end
  25.  
  26.  
  27. local randNum = math.random(1,maxVal)
  28. local chosenItem = GetRandomItems(randNum)
  29.  
  30. if chosenItem == "Scrap1" then
  31.     local clone = Folder:WaitForChild("Scrap1"):Clone()
  32.     clone.Parent = WorkFolder
  33.     clone.Position = Vector3.new(math.random(-255,255),math.random(0,10),math.random(-255,255))
  34.     Max.Value = Max.Value + 1
  35.     print(Max.Value)
  36.     Remote.Collect.OnServerEvent:Connect(function(plr, Part)
  37.         if Part:IsA("UnionOperation") and not Part == nil then
  38.             if ButtonPressed == false then
  39.         Part:Destroy()
  40.         ScrapValue.Scrap1.Value = ScrapValue.Scrap1.Value + 1
  41.         print(ScrapValue.Scrap1.Value)
  42.         Max.Value = Max.Value - 1
  43.         ButtonPressed = true
  44.         wait(0.5)
  45.         ButtonPressed = false
  46.            end
  47.         end
  48.     end)
  49. end
  50. if Max.Value >= 10 then
  51.     break
  52. end
  53. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top