Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Scrap = {
- {"Scrap1", 50},
- {"Scrap2", 25},
- {"Scrap3", 15},
- {"Scrap4", 5},
- {"Scrap5", 1},
- }
- while wait(1) do
- local maxVal = 0
- for pos,val in next, Scrap do
- maxVal = maxVal + val[2]
- end
- local function GetRandomItems (num)
- local Count = 0
- for pos,val in next, Scrap do
- Count = Count + val[2]
- if num <= Count then
- return val[1]
- end
- end
- return nil
- end
- local randNum = math.random(1,maxVal)
- local chosenItem = GetRandomItems(randNum)
- if chosenItem == "Scrap1" then
- local clone = Folder:WaitForChild("Scrap1"):Clone()
- clone.Parent = WorkFolder
- clone.Position = Vector3.new(math.random(-255,255),math.random(0,10),math.random(-255,255))
- Max.Value = Max.Value + 1
- print(Max.Value)
- Remote.Collect.OnServerEvent:Connect(function(plr, Part)
- if Part:IsA("UnionOperation") and not Part == nil then
- if ButtonPressed == false then
- Part:Destroy()
- ScrapValue.Scrap1.Value = ScrapValue.Scrap1.Value + 1
- print(ScrapValue.Scrap1.Value)
- Max.Value = Max.Value - 1
- ButtonPressed = true
- wait(0.5)
- ButtonPressed = false
- end
- end
- end)
- end
- if Max.Value >= 10 then
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement