-- Starter Character Scripts





function Death()
	wait(0.2)
	local Tool = script.Parent:FindFirstChildWhichIsA("Tool")
	if Tool then
		local M = script.Contain:Clone()
		M.Parent = game.Workspace
		M.Disabled = false
		if Tool:FindFirstChild("Handle") and script.Parent:FindFirstChildWhichIsA("Part") then
			Tool.Handle.Position = script.Parent:FindFirstChildWhichIsA("Part").Position
			Tool.Handle.Velocity = Vector3.new(0,0,0)
			Tool.Handle.RotVelocity = Vector3.new(0,0,0)
			Tool.Handle.CanCollide = true
			Tool.Parent = M
		end
	end
	local Player = game.Players:GetPlayerFromCharacter(script.Parent)
	if Player then
		local Value = 0
		local M = script.Contain:Clone()
		M.Parent = game.Workspace
		M.Disabled = false
		while true do
			local C = Player.Backpack:GetChildren()
			if #C <= 0 or (script.Configuration.DropAll.Value == false and Value >= script.Configuration.DropLimit.Value) then
				break
			end
			for i = 1,#C do
				if math.random(1,1000) == 1000 then
					if C[i]:FindFirstChild("Handle") and Player.Character:FindFirstChildWhichIsA("Part") then
						C[i].Handle.Position = Player.Character:FindFirstChildWhichIsA("Part").Position
						C[i].Handle.Velocity = Vector3.new(0,0,0)
						C[i].Handle.RotVelocity = Vector3.new(0,0,0)
						C[i].Handle.CanCollide = true
						C[i].Parent = M
					end
					Value = Value + 1
				end
				if script.Configuration.DropAll.Value == false and Value >= script.Configuration.DropLimit.Value then
					break
				end
			end
		end
	end
end
script.Parent.Humanoid.Died:connect(Death)
