Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local rnd = Random.new()
- local minTimePerDrop = 2
- local maxTimePerDrop = 6
- local minFallVelocity = -5
- local maxFallVelocity = -15
- local tools = game.ReplicatedStorage.Tools:GetChildren()
- while true do
- task.wait(rnd:NextNumber(minTimePerDrop, maxTimePerDrop))
- local drop = script:WaitForChild("Drop"):Clone()
- local randomPos = Vector3.new(
- rnd:NextNumber(-512, 512),
- 200,
- rnd:NextNumber(-512, 512))
- local newCF = CFrame.new(randomPos) * CFrame.Angles(0, rnd:NextNumber(0, 2 * math.pi), 0)
- drop:PivotTo(newCF)
- local atch0 = Instance.new("Attachment")
- atch0.Name = "Attachment0"
- atch0.Parent = drop.Crate
- local lv = Instance.new("LinearVelocity")
- lv.MaxForce = math.huge
- lv.RelativeTo = Enum.ActuatorRelativeTo.World
- lv.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
- lv.VectorVelocity = Vector3.new(
- rnd:NextNumber(-5, 5),
- rnd:NextNumber(maxFallVelocity, minFallVelocity),
- rnd:NextNumber(-5, 5))
- lv.Attachment0 = atch0
- lv.Parent = drop.Crate
- local av = Instance.new("AngularVelocity")
- av.MaxTorque = math.huge
- av.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
- av.AngularVelocity = Vector3.new(0, rnd:NextNumber(-1, 1), 0)
- av.Attachment0 = atch0
- av.Parent = drop.Crate
- drop.Crate.Touched:Connect(function(hit)
- local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
- if plr and hit.Parent.Humanoid.Health > 0 then
- drop:Destroy()
- local random = math.random(1, #tools)
- local newTool = tools[random]:Clone()
- newTool.Parent = plr.Backpack
- end
- end)
- drop.Parent = workspace
- task.spawn(function()
- repeat
- task.wait(1)
- until not drop or drop.Parent ~= workspace or drop.Crate.AssemblyLinearVelocity.Y > minFallVelocity
- if drop and drop.Parent == workspace then
- lv:Destroy()
- av:Destroy()
- atch0:Destroy()
- drop.Crate.Parachute:Destroy()
- drop.Parachute.CanCollide = false
- game:GetService("Debris"):AddItem(drop.Parachute, 5)
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement