View difference between Paste ID: aGyN2Uxv and 4iNxHfD7
SHOW: | | - or go back to the newest paste.
1
local rnd = Random.new()
2
3
4
local minTimePerDrop = 2
5
local maxTimePerDrop = 6
6
7
8
local minFallVelocity = -5
9
local maxFallVelocity = -15
10
11
12
local tools = game.ReplicatedStorage.Tools:GetChildren()
13
14
15
while true do
16
   
17
    task.wait(rnd:NextNumber(minTimePerDrop, maxTimePerDrop))
18
   
19
    local drop = script:WaitForChild("Drop"):Clone()
20
   
21
    local randomPos = Vector3.new(
22
        rnd:NextNumber(-512, 512),
23
        200,
24
        rnd:NextNumber(-512, 512))
25
    local newCF = CFrame.new(randomPos) * CFrame.Angles(0, rnd:NextNumber(0, 2 * math.pi), 0)
26
    drop:PivotTo(newCF)
27
28
29
    local atch0 = Instance.new("Attachment")
30
    atch0.Name = "Attachment0"
31
    atch0.Parent = drop.Crate
32
   
33
    local lv = Instance.new("LinearVelocity")
34
    lv.MaxForce = math.huge
35
    lv.RelativeTo = Enum.ActuatorRelativeTo.World
36
    lv.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
37
    lv.VectorVelocity = Vector3.new(
38
        rnd:NextNumber(-5, 5),
39
        rnd:NextNumber(maxFallVelocity, minFallVelocity),
40
        rnd:NextNumber(-5, 5))
41
    lv.Attachment0 = atch0
42
    lv.Parent = drop.Crate
43
   
44
    local av = Instance.new("AngularVelocity")
45
    av.MaxTorque = math.huge
46
    av.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
47
    av.AngularVelocity = Vector3.new(0, rnd:NextNumber(-1, 1), 0)
48
    av.Attachment0 = atch0
49
    av.Parent = drop.Crate
50
   
51
   
52
    drop.Crate.Touched:Connect(function(hit)
53
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
54
       
55
        if plr and hit.Parent.Humanoid.Health > 0 then
56
           
57
            drop:Destroy()
58
           
59
            local random = math.random(1, #tools)
60
           
61
            local newTool = tools[random]:Clone()
62
           
63
            newTool.Parent = plr.Backpack
64
        end
65
    end)
66
   
67
    drop.Parent = workspace
68
   
69
    task.spawn(function()
70
        repeat
71
            task.wait(1)
72
        until not drop or drop.Parent ~= workspace or drop.Crate.AssemblyLinearVelocity.Y > minFallVelocity
73
       
74
        if drop and drop.Parent == workspace then
75
            lv:Destroy()
76
            av:Destroy()
77
            atch0:Destroy()
78
           
79
            drop.Crate.Parachute:Destroy()
80
            drop.Parachute.CanCollide = false
81
           
82
            game:GetService("Debris"):AddItem(drop.Parachute, 5)
83
        end
84
    end)
85
end
86