-- Create debris for specified part (being destroyed)	

local function createDebris(targetPart)
	local pos = Vector3.new(0, 0, 0)
	local scale = 1
	
	if targetPart:IsA("Model") then
		local plate = targetPart:FindFirstChild("Plate", true)
		pos = plate.Position
		scale = plate.Size.X/8
	else
		pos = targetPart.Position
		scale = targetPart.Size.X/8
	end	
	
	local debris = debrisParts[math.random(1, #debrisParts)]:Clone()
	--local pos2 = getPositionRelativetoBase(debris.PrimaryPart, pos)
	local pos2 = pos
	debris:SetPrimaryPartCFrame(CFrame.new(pos2))
	scaleModel(debris, scale)
	debris.Parent = mapManager.getMap()
	
	targetPart:Destroy()
	
	return debris.PrimaryPart
end
